pbootcms默认生成的sitemap.xml中是不含tag标签链接的,如果我们想要实现在sitemap.xml直接生成tags标签,这个要怎么操作呢?
养好习惯,修改这些文件之前做好备份。
一、打开/apps/home/model/SitemapModel.php,在78行后面增加个指定分类标签调用代码。
01
// 指定分类标签调用
02
public function getSortTags($scode)
03
{
04
$join = array(
05
array(
06
\’ay_content_sort b\’,
07
\’a.scode=b.scode\’,
08
\’LEFT\’
09
),
10
array(
11
\’ay_model c\’,
12
\’b.mcode=c.mcode\’,
13
\’LEFT\’
14
)
15
);
16
17
$scode_arr = array();
18
if ($scode) {
19
// 获取所有子类分类编码
20
$this->scodes = array(); // 先清空
21
$scodes = $this->getSubScodes(trim($scode)); // 获取子类
22
23
// 拼接条件
24
$scode_arr = array(
25
\”a.scode in (\” . implode_quot(\’,\’, $scodes) . \”)\”,
26
\”a.subscode=\’$scode\’\”
27
);
28
}
29
$result = parent::table(\’ay_content a\’)->where(\’a.status=1\’)->where(\”c.type=2 AND a.tags<>\’\’\”)
30
->where($scode_arr, \’OR\’)
31
->join($join)
32
->order(\’a.visits DESC\’)
33
->column(\’a.tags\’);
34
return $result;
35
}
二、打开/apps/home/controller/SitemapController.php,在73行后面增加
01
if (! ! $rs = $this->model->getSortTags(\’\’)) {
02
$tags = implode(\’,\’, $rs); // 把栏目tags串起来 AB模板网
03
$tags = array_unique(explode(\’,\’, $tags)); // 再把所有tags组成数组并去重
04
foreach ($tags as $key2 => $value2) {
05
if (! in_array($value2, array_column($data, \’tags\’))) { // 制止重复输出
06
$url_rule_type = $this->config(\’url_rule_type\’) ?: 3;
07
if ($url_rule_type == 3) {
08
$link2 = Url::home(\’tag=\’ . urlencode($value2), \’\’);
09
} else {
10
$link2 = Url::home(\’tag/\’ . urlencode($value2));
11
}
12
$str .= $this->makeNode($link2, date(\’Y-m-d\’), \’0.80\’);
13
}
14
}
15
}
本网站名称:创码者资源网
本站永久网址: http://www.cmzym.top/
本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。
本站为非盈利网站,一切付费内容(包括但不限于会员充值,资源付费),均为用户自愿赞助,且所有资金均用于网站维护
本站资源均收录于互联网,所以不能保证每个细节都符合你的要求,也可能存在未知的BUG与瑕疵,因虚拟资源可复制特性,所以不接受任何理由的退款兑现,请阅 读本站声明和相关条款后再进行支付下载
本站一切资源不代表本站立场,并不代表本站赞同其观点和对其真实性负责。
本网站的文章部分内容可能来源于网络,仅供大家学习与参考,如有侵权,请联系站长 :1326632303@qq.com 进行删除处理。
本本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可
暂无评论内容