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

分  类: pbootcms教程

统  计:341 次获取

创建时间: 2024-03-21 14:47:24

  • 详情介绍
13+年专注全栈开发,承接小程序开发,分销系统定制,网站建设、搬家、搭建,二次开发等一站服务,欢迎咨询
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'); } }}

PbootCMS生成的sitemap.xml中增加tag标签链接_pbootcms教程 栏目文章由:源码庄整理发布,转载请注明来源。
来源地址:https://www.codenet.cc/article/details/475.html
本站资源未标注正版授权软件均为会员提供或网上搜集,版权归原作者所有,如需商业用途或转载请与原作者联系;
发布的文章及附件仅限用于学习和研究目的,请勿用于商业或违法用途!如有侵权,请及时联系我们!
《更多用户服务协议声明》
  • 波浪
  • 波浪
  • 波浪
  • 波浪