雷火电竞-中国电竞赛事及体育赛事平台

歡迎來(lái)到入門(mén)教程網(wǎng)!

phpcms

當(dāng)前位置:主頁(yè) > CMS教程 > phpcms >

PHPCMS V9評(píng)論模塊偽靜態(tài)與TAG模塊偽靜態(tài)設(shè)置

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:phpcms|點(diǎn)擊:

一、評(píng)論模塊偽靜態(tài)設(shè)置
1、首先在后臺(tái)->擴(kuò)展->url規(guī)則里添加一個(gè)新的規(guī)則用于評(píng)論模塊,如下面所示:
{$commentid}_{$page}.html添加完成后記住前面的id號(hào),比如31。
2、本來(lái)PC標(biāo)簽支持urlrule呢,后來(lái)不支持了,只好改代碼了,于是打開(kāi)文件phpcms/modules/comment/index.php找到:

復(fù)制代碼
代碼如下:

include template('comment', 'list');

在它上面添加幾行用于讀取urlrule和從評(píng)論表中調(diào)用評(píng)論數(shù)據(jù),對(duì)了,評(píng)論表是帶分表的。

復(fù)制代碼
代碼如下:

$page = intval($_GET['page']);
$page = max($page,1);
$urlrules = getcache('urlrules','commons');
$urlrule = $urlrules[31];//調(diào)用url規(guī)則
$pagesize = 10; //分頁(yè)大小
$comment_db = pc_base::load_model('comment_model');
$comment_data_db = pc_base::load_model('comment_data_model');
$comment = $comment_db->get_one(array('commentid'=>$commentid, 'siteid'=>$siteid));
if ($comment){
$comment_data_db->table_name($comment['tableid']);
$comment_info = $comment_data_db->listinfo(Array('commentid'=>$commentid,'status'=>1) , 'id desc', $page ,$pagesize,'','10',$urlrule,Array('commentid'=>$commentid));
$pages = $comment_data_db->pages;
}

3、下面就就改模版了,改模版其實(shí)就是改一下那個(gè)pc標(biāo)簽,只留下循環(huán)那里就可以了, 就是把那個(gè)調(diào)用評(píng)論數(shù)據(jù)的標(biāo)簽改改, 刪掉這個(gè)文件phpcmstemplatesdefaultcommentlist.html里的:

復(fù)制代碼
代碼如下:

{pc:comment action="lists" commentid="$commentid" siteid="$siteid" page="$_GET[page]" hot="$hot" num="20"}

和它對(duì)應(yīng)的那個(gè):

復(fù)制代碼
代碼如下:

{/pc}

然后把循環(huán)語(yǔ)句:

復(fù)制代碼
代碼如下:

{loop $data $r}

改成:

復(fù)制代碼
代碼如下:

{loop $comment_info $r}

把分頁(yè)標(biāo)簽:

復(fù)制代碼
代碼如下:

{$pages}

改成:

復(fù)制代碼
代碼如下:

{str_replace("_0.html","_1.html",$pages)}

4、最后在.htaccess文件里加入以下代碼:

復(fù)制代碼
代碼如下:

RewriteRule ^content_(.*)_([0-9]+).html index.php?m=comment&c=index&a=init&commentid=content_$1&page=$2

ok,現(xiàn)在就大功告成了,顯示出來(lái)的網(wǎng)址是:
/content_9-1-1_2.html
二、TAG模塊偽靜態(tài)設(shè)置
1、在后臺(tái)->擴(kuò)展->url規(guī)則里添加一個(gè)新的規(guī)則用于評(píng)論模塊,如下面所示:
{$tag}_{$catid}_{$page}.html 添加完成后記住前面的id號(hào),比如32。
2、打開(kāi)phpcms/modules/content/tag.php文件,找到:

復(fù)制代碼
代碼如下:

$total = $this->db->number;

這一行往上面添加以下代碼:

復(fù)制代碼
代碼如下:

$siteid = $this->categorys[$catid]['siteid'];
$siteurl = siteurl($siteid);
$this->db->set_model($modelid);
$page = $_GET['page'];
$urlrules = getcache('urlrules','commons');
$urlrule = $urlrules[32];//調(diào)用url規(guī)則
$datas = $infos = array();
$infos = $this->db->listinfo("`keywords` LIKE '%$tag%'",'id DESC',$page,25,'','9',$urlrule,Array('catid'=>$catid,'tag'=>urlencode($tag)));

3、修改模板,打開(kāi)phpcmstemplatesdefaultcontentshow.html,找到:

復(fù)制代碼
代碼如下:

{APP_PATH}index.php?m=content&c=tag&catid={$catid}&tag={urlencode($keyword)}

改成:

復(fù)制代碼
代碼如下:

{APP_PATH}{urlencode($keyword)}_{$catid}_1.html

打開(kāi)phpcmstemplatesdefaultcontenttag.html,把分頁(yè)標(biāo)簽:

復(fù)制代碼
代碼如下:

{$pages}

改成:

復(fù)制代碼
代碼如下:

{str_replace("_0.html","_1.html",$pages)}

4、在.htaccess文件里加入以下代碼:

復(fù)制代碼
代碼如下:

RewriteRule ^(.*)_([0-9]+)_([0-9]+).html index.php?m=content&c=tag&catid=$2&tag=$1&page=$3

最后顯示出來(lái)的URL樣式如下:
/關(guān)鍵詞_6_1.html
小結(jié):其實(shí)以上的修改都是在listinfo支持偽靜態(tài)規(guī)則的基礎(chǔ)上來(lái)修改的,熟練使用listinfo,就能在phpcms的任何頁(yè)面實(shí)現(xiàn)偽靜態(tài)分頁(yè)了。

上一篇:phpcms 的sso通信失敗的解決和思路

欄    目:phpcms

下一篇:phpcms緩存使用總結(jié)(memcached、eaccelerator、shm)

本文標(biāo)題:PHPCMS V9評(píng)論模塊偽靜態(tài)與TAG模塊偽靜態(tài)設(shè)置

本文地址:http://www.jygsgssxh.com/a1/phpcms/9870.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有