您现在的位置是:首页 > 教程 > pbootcms教程pbootcms教程

pbootcms生成sitemap.xml中增加tag标签的方法实例

紫翠2025-02-11 14:34:40pbootcms教程已有5人查阅

导读问题描述:PbootCMS默认生成的 sitemap.xml 不包含 tag 标签链接。解决方法:打开 /apps/home/model/SitemapModel.php,在第78行后增加以下代码:

问题描述:PbootCMS默认生成的 sitemap.xml 不包含 tag 标签链接。
解决方法:
打开 /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;
}
打开 /apps/home/controller/SitemapController.php,在第73行后增加以下代码:
if (!empty($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 =. urlencode($value2), '');
} else {
$link2 =. urlencode($value2));
}
$str .= $this->makeNode($link2, date('Y-m-d'), '0.80');
}
}
}

本文标签:

很赞哦! (0)

暂无内容
暂无内容

相关文章

暂无内容
暂无内容
留言与评论 (共有 0 条评论)
昵称:
匿名发表 登录账号
         
验证码: