国产人成精品香港三级在-国产人成精品香港三级古代-国产人成-国产全黄a一级毛片视频-日本伦理网站-日本乱码一卡二卡三卡永久

+ 收藏我們

網站模板

網站模板搜索
404模板 營銷型模板 外貿網站模板 單頁模板 雙語模板 標簽大全

注冊
網站模板 > cms教程 > pbootcms教程 >

PbootCMS生成的sitemap.xml中增加tag標簽鏈接

AB模板網 / 2023-09-08
pbootcms默認生成的sitemap.xml中是不含tag標簽鏈接的,如果我們想要實現在sitemap.xml直接生成tags標簽,這個要怎么操作呢?

養好習慣,修改這些文件之前做好備份。
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串起來 AB模板網
    $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');
        }
    }
}

文章搜集與網絡,如有侵權請聯系本站,轉載請說明出處:http://www.tbwwir.cn/pbootcmsjs/10743.html
X

截屏,微信識別二維碼

微信號:wwwadminbuycn

(點擊微信號復制,添加好友)

  打開微信

 
咨詢
QQ在線咨詢

如無回復
請加下面的微信

添加微信客

微信客服
wwwadminbuycn