DedeCMS的系统TAGS确实是一个非常好的功能,通过关键词链接可以快速寻找到相关内容,不过很多人希望能够将TAGS静态化这样更加利于SEO,CIT.CN也是对此进行了优化和调整,只不过cit小虫觉得这种更新内容比较频繁的列表最好采用伪静态的方式,这里就分享下技巧。
1.修改前台显示链接
我们这里达到的效果就是使原来/tags.php?keywors更改为/tags/keywords.html。
这里主要修改下调用的标签,在includetaglibtag.lib.php中,在87行找到
| | 1 | $row['link'] = $cfg_cmsurl."/tags?".urlencode($row['keyword']); | 
 | 
将其改为:
| | 1 | $row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword']).".html"; | 
 | 
2.修改分页代码
我们需要修改include/arc.taglist.class.php,将分页函数替换为:
| | 005 | * @param     int  $list_len  列表宽度 | 
| 006 | * @param     string  $listitem  列表样式 | 
| 009 | functionGetPageListDM($list_len,$listitem="info,index,end,pre,next,pageno") | 
| 013 | $prepagenum = $this->PageNo - 1; | 
| 014 | $nextpagenum = $this->PageNo + 1; | 
| 015 | if($list_len == ""|| preg_match("/[^0-9]/", $list_len)) | 
| 019 | $totalpage = $this->TotalPage; | 
| 020 | if($totalpage <= 1 && $this->TotalResult > 0) | 
| 022 | return"<span class="pageinfo">共1页/".$this->TotalResult."条</span>"; | 
| 024 | if($this->TotalResult == 0) | 
| 026 | return"<span class="pageinfo">共0页/".$this->TotalResult."条</span>"; | 
| 028 | $maininfo = "<span class="pageinfo">共{$totalpage}页/".$this->TotalResult."条</span>rn"; | 
| 029 | $purl = $this->GetCurUrl(); | 
| 030 | $basename= basename($purl); | 
| 031 | $tmpname = explode('.', $basename); | 
| 033 | $purl = str_replace($basename, '', $purl).urlencode($this->Tag); | 
| 034 | //var_dump($purl);exit; | 
| 035 | //$purl .= "?/".urlencode($this->Tag); | 
| 038 | if($this->PageNo != 1) | 
| 040 | $prepage.="<li><a href='".$purl."-$prepagenum'.html>上一页</a></li>rn"; | 
| 041 | $indexpage="<li><a href='".$purl."-1.html'>首页</a></li>rn"; | 
| 045 | $indexpage="<li><a>首页</a></li>rn"; | 
| 047 | if($this->PageNo!=$totalpage && $totalpage>1) | 
| 049 | $nextpage.="<li><a href='".$purl."-$nextpagenum.html'>下一页</a></li>rn"; | 
| 050 | $endpage="<li><a href='".$purl."-$totalpage.html'>末页</a></li>rn"; | 
| 054 | $endpage="<li><a>末页</a></li>rn"; | 
| 059 | $total_list = $list_len * 2 + 1; | 
| 060 | if($this->PageNo >= $total_list) | 
| 062 | $j = $this->PageNo - $list_len; | 
| 063 | $total_list = $this->PageNo + $list_len; | 
| 064 | if($total_list > $totalpage) | 
| 066 | $total_list = $totalpage; | 
| 072 | if($total_list > $totalpage) | 
| 074 | $total_list = $totalpage; | 
| 077 | for($j; $j<=$total_list; $j++) | 
| 079 | if($j == $this->PageNo) | 
| 081 | $listdd.= "<li class="thisclass"><a>$j</a></li>rn"; | 
| 085 | $listdd.="<li><a href='".$purl."-$j.html'>".$j."</a></li>rn"; | 
| 089 | if(preg_match('/info/i', $listitem)) | 
| 091 | $plist .= $maininfo.' '; | 
| 093 | if(preg_match('/index/i', $listitem)) | 
| 095 | $plist .= $indexpage.' '; | 
| 097 | if(preg_match('/pre/i', $listitem)) | 
| 099 | $plist .= $prepage.' '; | 
| 101 | if(preg_match('/pageno/i', $listitem)) | 
| 103 | $plist .= $listdd.' '; | 
| 105 | if(preg_match('/next/i', $listitem)) | 
| 107 | $plist .= $nextpage.' '; | 
| 109 | if(preg_match('/end/i', $listitem)) | 
| 111 | $plist .= $endpage.' '; | 
 | 
我们这里以iis7为例子,设置以下规则:
| | 01 | <?xml version="1.0"encoding="UTF-8"?> | 
| 11 | <rule name="weather1"stopProcessing="true"> | 
| 13 | <match url="tags/([^-]+).html$"ignoreCase="true"/> | 
| 15 | <conditions logicalGrouping="MatchAll"> | 
| 17 | <add input="{REQUEST_FILENAME}"matchType="IsFile"negate="true"/> | 
| 19 | <add input="{REQUEST_FILENAME}"matchType="IsDirectory"negate="true"/> | 
| 23 | <action type="Rewrite"url="/tags.php?/{R:1}"appendQueryString="false"/> | 
| 27 | <rule name="weather2"stopProcessing="true"> | 
| 29 | <match url="tags/([^-]+)-([0-9]+).html$"ignoreCase="true"/> | 
| 31 | <conditions logicalGrouping="MatchAll"> | 
| 33 | <add input="{REQUEST_FILENAME}"matchType="IsFile"negate="true"/> | 
| 35 | <add input="{REQUEST_FILENAME}"matchType="IsDirectory"negate="true"/> | 
| 39 | <action type="Rewrite"url="/tags.php?/{R:1}/{R:2}"appendQueryString="false"/> | 
 | 
可以直接保存为web.config放在站点根目录。
4.重新生成html页面
这个操作就不用说了,全部重新生成下,至此全部修改完毕。
5.预览查看显示结果
至此,我们已经完成了所有的设置
	 
	 
	
郑重声明:
本站所有内容均由互联网收集整理、网友上传,并且以计算机技术研究交流为目的,仅供大家参考、学习,不存在任何商业目的与商业用途。
若您需要商业运营或用于其他商业活动,请您购买正版授权并合法使用。
我们不承担任何技术及版权问题,且不对任何资源负法律责任。
如无法下载,联系站长索要。
	如有侵犯您的版权,请给我们来信:cainiaovip8@qq.com,我们尽快处理。