大家都知道,Phpcms V9默认的标签Tag的路径URL是:
http://www.cmsyou.com/index.php?m=content&c=tag&catid=10&tag=cmsyou
1、修改程序文件,做到从源头支持伪静态,找到文件:\phpcms\modules\content\tag.php
查找:
$page = $_GET['page'];$datas = $infos = array();$infos = $this->db->listinfo("`keywords` LIKE '%$tag%'",'id DESC',$page,20);$total = $this->db->number;if($total>0) {$pages = $this->db->pages;foreach($infos as $_v) {if(strpos($_v['url'],'://')===false) $_v['url'] = $siteurl.$_v['url'];$datas[] = $_v;}}
修改为:
$page = isset($_GET['page'])?$_GET['page']:1;$datas = $infos = array();$tag = iconv("utf-8","gb2312",$tag); //CMSYOU转编码$infos = $this->db->listinfo("`keywords` LIKE '%$tag%'",'id DESC',$page,10);$total = $this->db->number;define('URLRULE',$siteurl.'/tags/'.$tag.'/'.$catid.'-{$page}.html');//伪静态后的翻页修正if($total>0) {$pages = pages($total,$page,10,URLRULE,array(),10) ;foreach($infos as $_v) {if(strpos($_v['url'],'://')===false) $_v['url'] = $siteurl.$_v['url'];$datas[] = $_v;}}
2、修改伪静态规则,下面以.htaccess文件为例说说伪静态规则。
RewriteRule ^tags/(.*)/([0-9]+)-([0-9]+).html$ index.php?m=content&c=tag&catid=$2&tag=$1&page=$3
添加上面这条伪静态规则。这样就修改后,程序上支持伪静态了:
你的域名/tags/cmsyou标签名/10-1.html
3、在模板前端显示中,具体修改打开内容页模版:content/show.html找到
<a href="{APP_PATH}index.php?m=content&c=tag&a=lists&tag={urlencode($keyword)}" class="blue">{$keyword}</a>
<a href="{APP_PATH}tags/{$keyword}/{$catid}-1.html" class="cmsyou">{$keyword}</a>
同时欢迎大家收听CMSYOU官方微博 或者到互助论坛发问,相互探讨Phpcms!
点击加载更多