cms使用过程中,会遇到父栏目直接链接到第一个子栏目的情况,最方便的方法就行栏目设置填写外链,即直接填写/xxx.html,这样生成的网站地图中的这个栏目链接也就变成/xxx.html了,不会自带域名,下面是修复办法
1.indexController.php加入以下函数

//生成完整链接函数
function completeUrl($url, $siteDomain) {
    if (preg_match('~^https?://~i', $url)) {
        return $url;
    }
    $domain = rtrim($siteDomain, '/');
    $path = ltrim($url, '/');
    return $domain . '/' . $path;
}

2.在文件下面找到网站地图生成函数,在栏目逻辑这里应用函数

 if($v=='classtype'){
    foreach($list as $s){
      if($this->classtypedata[$s['id']]['url']){
         if($cachedata){
             echo $this->completeUrl($this->classtypedata[$s['id']]['url'], $www).'<br>';
          }
          if($filetype=='xml'){
              $l_pc.='<url>
        <loc>'.$this->completeUrl($this->classtypedata[$s['id']]['url'], $www).'</loc>
            <lastmod>'.date('Y-m-d').'T08:00:00+00:00</lastmod>
            <changefreq>'.$freq[$k].'</changefreq>
            <priority>'.$priority[$k].'</priority>
             </url>';

标签: 极致cms

您需要先登录才能发表评论。