tag.html 模板頁,增加 分頁功能及其配套的偽靜態(tài)和路由適配。
問題:
{cache name=module-content return=c}
{related module=$c.dirname tag=$tag.tags page=1 pagesize=10 urlrule=/index.php?s=tag&name=$get.name&page=[page]}
<a href="{$t.url}">{$t.title}</a>
{/related}
{/cache}
<!-- 下面是分頁標(biāo)簽 -->
<div class="pages">
{$pages}
</div>關(guān)鍵詞庫插件里,已經(jīng)配置了tag偽靜態(tài)URL。
tag/xxxx.html
訪問 tag/xxx.html 頁,會通過 上面的循環(huán)標(biāo)簽輸出包含這個(gè) {$get.name} 關(guān)鍵詞的所有數(shù)據(jù),
現(xiàn)在要實(shí)現(xiàn)分頁功能,按照apdwn.com的教程,已經(jīng)加了相關(guān)分頁參數(shù),
并且,動(dòng)態(tài) 分頁模式下,分頁正常
/index.php?s=tag&name=hua&page=2
要實(shí)現(xiàn)的最終效果:
把 /index.php?s=tag&name=hua&page=2
這條動(dòng)態(tài)分頁 URL ,重寫路由偽靜態(tài)實(shí)現(xiàn)
tag/xxxx/2.html
xxxx 是 關(guān)鍵詞轉(zhuǎn)拼音 也就是 {$get.name} 獲取到的關(guān)鍵詞
2.html 2是分頁頁碼
組合起來就是 tag/xxxx/2.html
目前,官網(wǎng)后臺現(xiàn)有的偽靜態(tài)功能,已經(jīng)可以訪問 /tag/hua.html
但是在 /tag/hua.html 頁,實(shí)現(xiàn)自定義URL偽靜態(tài)就不行了
比如 /tag/hua/2.html
2 分頁頁碼,
就不行了。所以要按照 我上面的需求改進(jìn)。
試試下面規(guī)則 加到/config/rewrite.php 里面去
// TAG關(guān)鍵詞---解析規(guī)則----開始 "tag\/(.+)\/([0-9]+).html" => "index.php?s=tag&name=$1&page=$2", //【TAG關(guān)鍵詞】TagURL(tag/{tag}/{page}.html) // TAG關(guān)鍵詞---解析規(guī)則----結(jié)束本身規(guī)則就是這樣寫的,光這樣弄不行。
回復(fù)@K大帥
我測試的也是識別不出來
好像和標(biāo)簽有類關(guān)系 優(yōu)先識別子類的
需要在 config/custom.php 里 函數(shù)識別
回復(fù)@K大帥
那不知道了 得問下老大如何弄。。
第一步
"tag\/([a-z]+).html" => "index.php?s=tag&name=$1", //【tag】TagURL(tag/{tag}.html)
"tag\/([a-z]+)\/([0-9]+).html" => "index.php?s=tag&name=$1&page=$2",
第二部
{cache name=module-content return=c}
{related module=$c.dirname tag=$tag.tags page=1 pagesize=10 urlrule=tag/$get.name/[page].html}
<li class="text-truncate"><a href="{$t.url}">{$t.title} —— <span class="text-danger">{$t.zuozhe}</span>《{$t.shiming}》</a></li>
{/related}
{/cache}
搞定,快點(diǎn)給我錢
config/rewrite.php
<?ph $rule ="tag-".$get.name."-[page].html"; ?>
{related module=$c.dirname tag=$tag.tags page=1 pagesize=10 urlrule=$rule}
你這個(gè)循環(huán)體里面分頁啊,我覺得不現(xiàn)實(shí),因?yàn)橐粋€(gè)頁面只能有一個(gè)分頁標(biāo)簽
兄弟啊,,tag.html 模板頁,本來就一個(gè) {$pages} 分頁啊。。。
回復(fù)@易學(xué)習(xí)