pbootcms生成的sitemap.xml中增加tag標簽鏈接
pbootcms生成的sitemap.xml和sitemap.txt中默認是不含tag標簽鏈接的,如果想增加怎么辦,下來來介紹下如何二開實現。實現后如下圖,所有的tag鏈接都會進去。
實現步驟
1、實現sitemap.xml中增加tag頁面url
打開/apps/home/controller/SitemapController.php,找到echo $str . "\n</urlset>";在上方增加:
$parser_model = model('home.Parser'); if (! ! $rs = $parser_model->getSortTags('')) { $tags = implode(',', $rs); // 把欄目tags串起來 $tags = array_unique(explode(',', $tags)); // 再把所有tags組成數組并去重 foreach ($tags as $key2 => $value2) { if (! in_array($value2, array_column($tags, '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'); } } }
截圖:
2、實現sitemap.txt中增加tag頁面url
打開/apps/home/controller/SitemapController.php,找到echo $str;在上方增加:
$parser_model = model('home.Parser'); if (! ! $rs = $parser_model->getSortTags('')) { $tags = implode(',', $rs); // 把欄目tags串起來 $tags = array_unique(explode(',', $tags)); // 再把所有tags組成數組并去重 foreach ($tags as $key2 => $value2) { if (! in_array($value2, array_column($tags, '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 .= get_http_url() . $link2 . "\n"; } } }
截圖:
完成以上兩步后即可實現sitemap.xml和sitemap.txt中調用tag鏈接。
如果您的問題還未解決可以聯系站長付費協助。

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