PbootCMS生成的sitemap.xml中增加tag标签链接
pbootcms默认生成的sitemap.xml中是不含tag标签链接的,如果我们想要实现在sitemap.xml直接生成tags标签,这个要怎么操作呢?
养好习惯,修改这些文件之前做好备份。
1、打开/apps/home/model/SitemapModel.php,在78行后面增加个指定分类标签调用代码。
02 |
public function getSortTags($scode) |
20 |
$this->scodes = array(); // 先清空 |
21 |
$scodes = $this->getSubScodes(trim($scode)); // 获取子类 |
25 |
"a.scode in (" . implode_quot( ',' , $scodes) . ")" , |
29 |
$result = parent::table( 'ay_content a' )->where( 'a.status=1' )->where( "c.type=2 AND a.tags<>''" ) |
30 |
->where($scode_arr, 'OR' ) |
32 |
->order( 'a.visits DESC' ) |
|
2、打开/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), '' ); |
10 |
$link2 = Url::home( 'tag/' . urlencode($value2)); |
12 |
$str .= $this->makeNode($link2, date ( 'Y-m-d' ), '0.80' ); |
|