PbootCMS生成的sitemap.xml中增加tag標簽鏈接
PbootCMS生成的sitemap.xml中默認是不含tag標簽鏈接的,如果想增加怎么辦,下來來介紹下如何二開實現。實現后如下圖,所有的tag鏈接都會進去。
二開步驟
1、打開/apps/home/model/SitemapModel.php,在78行后面增加個指定分類標簽調用代碼。
// 指定分類標簽調用 public function getSortTags($scode) { $join = array( array( 'ay_content_sort b', 'a.scode=b.scode', 'LEFT' ), array( 'ay_model c', 'b.mcode=c.mcode', 'LEFT' ) ); $scode_arr = array(); if ($scode) { // 獲取所有子類分類編碼 $this->scodes = array(); // 先清空 $scodes = $this->getSubScodes(trim($scode)); // 獲取子類 // 拼接條件 $scode_arr = array( "a.scode in (" . implode_quot(',', $scodes) . ")", "a.subscode='$scode'" ); } $result = parent::table('ay_content a')->where('a.status=1')->where("c.type=2 AND a.tags<>''") ->where($scode_arr, 'OR') ->join($join) ->order('a.visits DESC') ->column('a.tags'); return $result; }
截圖:
2、打開/apps/home/controller/SitemapController.php,在73行后面增加
if (! ! $rs = $this->model->getSortTags('')) { $tags = implode(',', $rs); // 把欄目tags串起來 $tags = array_unique(explode(',', $tags)); // 再把所有tags組成數組并去重 foreach ($tags as $key2 => $value2) { if (! in_array($value2, array_column($data, 'tags'))) { // 避免重復輸出 $url_rule_type = $this->config('url_rule_type') ?: 3; if ($url_rule_type == 3) { $link2 = Url::home('tag=' . urlencode($value2), ''); } else { $link2 = Url::home('tag/' . urlencode($value2)); } $str .= $this->makeNode($link2, date('Y-m-d'), '0.80'); } } }
截圖:
完成以上兩步后即可實現sitemap中調用tag鏈接,具體效果可以訪問本站sitemap文件查看sitemap.xml
如果您的問題還未解決可以聯系站長付費協助。

有問題可以加入技術QQ群一起交流學習
本站vip會員 請加入無憂模板網 VIP群(50604020) PS:加入時備注用戶名或昵稱
普通注冊會員或訪客 請加入無憂模板網 技術交流群(50604130)
客服微信號:15898888535
聲明:本站所有文章資源內容,如無特殊說明或標注,均為采集網絡資源。如若內容侵犯了原著者的合法權益,可聯系站長刪除。