目標(biāo):使DEDECMS原來(lái)的tags.php?/bnxbcom/ 變動(dòng)為/tags/bnxbcom.html 這種偽靜態(tài)模式
一、dede后臺(tái)開(kāi)啟偽靜態(tài)
二、修改 /include/taglib/tag.lib.php
大約87行找到
$row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";
改成
$row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword']).".html";
三、修改分頁(yè)代碼
修改分頁(yè)代碼。同樣打開(kāi)include/arc.taglist.class.php,主要是//獲得上一頁(yè)和下一頁(yè)的鏈接。將//獲得上一頁(yè)和下一頁(yè)的鏈接 至 //獲得數(shù)字鏈接之間的分頁(yè)函數(shù)替換:
也可以直接用下面代碼替換同樣部分代碼
(提示:網(wǎng)上有文章中講的以下代碼中的"pageinfo"是錯(cuò)誤的,應(yīng)該為/"pageinfo/",不然會(huì)有錯(cuò)誤提示哦!已經(jīng)代碼測(cè)試OK!)
/** * 獲取動(dòng)態(tài)的分頁(yè)列表** @access public* @param int $list_len 列表寬度* @param string $listitem 列表樣式* @return string*/function GetPageListDM($list_len,$listitem="info,index,end,pre,next,pageno"){$prepage="";$nextpage="";$prepagenum = $this->PageNo - 1;$nextpagenum = $this->PageNo + 1;if($list_len == "" || preg_match("/[^0-9]/", $list_len)){$list_len = 3;}$totalpage = $this->TotalPage;if($totalpage <= 1 && $this->TotalResult > 0){return "<span class=/"pageinfo/">共1頁(yè)/".$this->TotalResult."條</span>";}if($this->TotalResult == 0){return "<span class=/"pageinfo/">共0頁(yè)/".$this->TotalResult."條</span>";}$maininfo = "<span class=/"pageinfo/">共{$totalpage}頁(yè)/".$this->TotalResult."條</span>rn";$purl = $this->GetCurUrl();$basename = basename($purl);$tmpname = explode('.', $basename);$purl = str_replace($basename, '', $purl).urlencode($this->Tag);//var_dump($purl);exit;//$purl .= "?/".urlencode($this->Tag);//獲得上一頁(yè)和下一頁(yè)的鏈接if($this->PageNo != 1){$prepage.="<li><a href='".$purl."-$prepagenum'.html>上一頁(yè)</a></li>rn";$indexpage="<li><a href='".$purl."-1.html'>首頁(yè)</a></li>rn";}else{$indexpage="<li><a>首頁(yè)</a></li>rn";}if($this->PageNo!=$totalpage && $totalpage>1){$nextpage.="<li><a href='".$purl."-$nextpagenum.html'>下一頁(yè)</a></li>rn";$endpage="<li><a href='".$purl."-$totalpage.html'>末頁(yè)</a></li>rn";}else{$endpage="<li><a>末頁(yè)</a></li>rn";}//獲得數(shù)字鏈接$listdd="";$total_list = $list_len * 2 + 1;if($this->PageNo >= $total_list){$j = $this->PageNo - $list_len;$total_list = $this->PageNo + $list_len;if($total_list > $totalpage){$total_list = $totalpage;}}else{$j=1;if($total_list > $totalpage){$total_list = $totalpage;}}for($j; $j<=$total_list; $j++){if($j == $this->PageNo){$listdd.= "<li class=/"thisclass/"><a>$j</a></li>rn";}else{$listdd.="<li><a href='".$purl."-$j.html'>".$j."</a></li>rn";}}$plist = '';if(preg_match('/info/i', $listitem)){$plist .= $maininfo.' ';}if(preg_match('/index/i', $listitem)){$plist .= $indexpage.' ';}if(preg_match('/pre/i', $listitem)){$plist .= $prepage.' ';}if(preg_match('/pageno/i', $listitem)){$plist .= $listdd.' ';}if(preg_match('/next/i', $listitem)){$plist .= $nextpage.' ';}if(preg_match('/end/i', $listitem)){$plist .= $endpage.' ';}return $plist;} |
四、打開(kāi)templets/default/taglist.htm
找到
<strong>當(dāng)前位置:</strong>:<a href="{dede:global.cfg_cmsurl/}/">主頁(yè)</a> > <a href='tags.php'>TAG標(biāo)簽</a> > {dede:field.title /}
修改為
<strong>當(dāng)前位置:</strong>:<a href="{dede:global.cfg_cmsurl/}/">主頁(yè)</a> > <a href='/tags.html'>TAG標(biāo)簽</a> > {dede:field.title /}
五、httpd.ini 文件里加
RewriteRule ^(.*)/tags/.html $1/tags/.phpRewriteRule ^(.*)/tags/(.*).html $1/tags/.php/?$2如果是HTACCESS,那使用下面規(guī)則RewriteEngine onRewriteBase /RewriteRule ^tags/([0-9]+)_([0-9]+).html$ tags.php?tagid=$1&PageNo=$2 [L]RewriteRule ^tags/([0-9]+).html$ tags.php?tagid=$1 [L] |
新聞熱點(diǎn)
疑難解答
圖片精選