源码网_提供网站源码、discuz、wordpress主题与插件和站长教程等资源的下载服务

PbootCMS生成的sitemap.xml中增加tag标签链接

pbootcms默认生成的sitemap.xml中是不含tag标签链接的,如果我们想要实现在sitemap.xml直接生成tags标签,这个要怎么操作呢?

养好习惯,修改这些文件之前做好备份。
1、打开/apps/home/model/SitemapModel.php

,在78行后面增加个指定分类标签调用代码。

01// 指定分类标签调用
02public function getSortTags($scode)
03{
04$join = array(
05array(
06ay_content_sort b,
07a.scode=b.scode,
08LEFT
09),
10array(
11ay_model c,
12b.mcode=c.mcode,
13LEFT
14)
15);
16
17$scode_arr = array();
18if ($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);
34return $result;
35}
2、打开/apps/home/controller/SitemapController.php

,在73行后面增加

01if (! ! $rs = $this->model->getSortTags()) {
02$tags = implode(,, $rs); // 把栏目tags串起来 AB模板网
03$tags = array_unique(explode(,, $tags)); // 再把所有tags组成数组并去重
04foreach ($tags as $key2 => $value2) {
05if (! in_array($value2, array_column($data, tags))) { // 避免重复输出
06$url_rule_type = $this->config(url_rule_type) ?: 3;
07if ($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.7ov.cn/xinwendongtai/1823.html

版权声明:站内所有文章皆来自网络转载,只供模板演示使用,并无任何其它意义!

联系客服
网站客服 业务合作 在线客服QQ
294169012
微信号
微信号
微信号
返回顶部