久久久久av_欧美日韩一区二区在线_国产精品三区四区_日韩中字在线

Discuz! 官方交流社區

標題: Discuz! X3.4主題分類和分類信息偽靜態設置方法(親測可用) [打印本頁]

作者: allthebest    時間: 2019-7-21 19:59
標題: Discuz! X3.4主題分類和分類信息偽靜態設置方法(親測可用)
網上99%都是不完善和殘缺的 或者各種不兼容,有的論壇還復制別人的DZ3.2版本的偽靜態方法說是支持3.4版本的,全是讓人浪費時間。

A、主題分類偽靜態設置方法:

準備好修改的模板文件:forumdisplay.htm和forumdisplay_list.htm

這兩個文件都在 \template\default\forum 的目錄下(有修改過discuz模板,以你的主題文件路徑為準,如/template/主題模板文件夾/forum)。

我們要先修改主題分類的:打開forumdisplay.htm的源代碼:

默認主題一般在415行,當然如你的主題有修改過discuz模板,以你的主題文件路徑為準

1.修改forumdisplay.htm文件中

  1. <li><a href="forum.php?mod=forumdisplay&fid=$_G[fid]&filter=typeid&typeid=$id$forumdisplayadd[typeid]{if $_GET['archiveid']}&archiveid={$_GET['archiveid']}{/if}">
復制代碼


修改為:

  1. <li><a href="forumtype-$_G[fid]-$id-$page.html{if $_GET['archiveid']}&archiveid={$_GET['archiveid']}{/if}">
復制代碼


2.接下來再打開forumdisplay_list.htm的源代碼:默認主題一般在162行,如你的主題有修改過模板,以你的主題文件為準找到:

  1. <a href="forum.php?mod=viewthread&tid=$thread[tid]&{if $_GET['archiveid']}archiveid={$_GET['archiveid']}&{/if}extra=$extra"$thread[highlight]{if $thread['isgroup'] == 1 || $thread['forumstick']} target="_blank"{else} onclick="atarget(this)"{/if} class="s xst">$thread[subject]</a>
復制代碼


修改為:

  1. <a href="forum.php?mod=viewthread&tid=$thread[tid]{if $_G['gp_archiveid']}&archiveid={$_G['gp_archiveid']}{/if}"$thread[highlight]{if $thread['isgroup'] == 1 || $thread['forumstick']} target="_blank"{else} onclick="atarget(this)"{/if} class="s xst">$thread[subject]</a>
復制代碼


3.主題類別前綴【只顯示文字】,2個地方需要修改

i、打開source\module\forum\forum_forumdisplay.php,查找

  1. forum.php?mod=forumdisplay&fid='.$_G['fid'].'&filter=typeid&typeid='.$thread['typeid'].'
復制代碼


替換為:

  1. forumtype-'.$_G['fid'].'-'.$thread['typeid'].'-1.html
復制代碼


ii、打開模板目錄viewthread.htm,查找

  1. forum.php?mod=forumdisplay&fid=$_G[fid]&filter=typeid&typeid=$_G[forum_thread][typeid]
復制代碼


替換為:

  1. forumtype-$_G[fid]-{$_G[forum_thread][typeid]}-1.html
復制代碼


最后我們要把主題分類的偽靜態規則添加到相應文件中,規則如下

(因為環境問題,只測試了.htaccess,其它請自行測試):

.htaccess 偽靜態規則 請在RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1下面增加:

  1. RewriteCond %{QUERY_STRING} ^(.*)$
  2. RewriteRule ^forumtype-(\w+)-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&filter=typeid&typeid=$2&page=$3&%1
復制代碼


注意:增加的規則不能放最后,特別是不能 不能 不能放在插件規則RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1 :$2&%1之后,不然訪問分類偽靜態會出現“插件不存在或刪除”的錯誤。

httpd.ini 偽靜態規則

  1. RewriteRule ^(.*)/forumtype-(\w+)-(\w+)-([0-9]+)\.html(\?(.*))*$ $1/forum\.php\?mod=forumdisplay&fid=$2&filter=typeid&typeid=$3&page=$4&$5
復制代碼


web.config 偽靜態規則

  1. <rule name="forum_forumtype">
  2. <match url="^(.*/)*forumtype-(\w+)-(\w+)-([0-9]+).html\?*(.*)[ DISCUZ_CODE_2 ]quot; />
  3. <action type="Rewrite" url="{R:1}/forum.php\?mod=forumdisplay&fid={R:2}&filter=typeid&typeid={R:3}&page={R:4}&{R:5}" />
  4. </rule>
復制代碼


B、分類信息列表內的帖子設置偽靜態方法:

打開 forum/forumdisplay_list.htm 模板,將

  1. <a href="forum.php?mod=viewthread&tid=$thread[tid]&{if $_GET['archiveid']}archiveid={$_GET['archiveid']}&{/if}extra=$extra"$thread[highlight]{if $thread['isgroup'] == 1 || $thread['forumstick']} target="_blank"{else}{/if} class="s xst">$thread[subject]</a>
復制代碼


替換為:

  1. <a href="forum.php?mod=viewthread&tid=$thread[tid]"{$thread[highlight]} {if $thread['isgroup'] == 1 || $thread['forumstick']}target="_blank"{else}onclick="atarget(this)"{/if} class="s xst">$thread[subject]</a>
復制代碼


修改后,當選中分類時,列表中的帖子鏈接將為偽靜態,但帖子的分頁鏈接仍是動態,還需進行以下修改。

打開 source/module/forum/forum_forumdisplay.php 文件,將

  1. <a href="forum.php?mod=viewthread&tid=$realtid&".(!empty($multipate_archive) ? "$multipate_archive&" : '')."extra=$extra&page=$i">
復制代碼


替換為:

  1. <a href="thread-$realtid-$i-1.html">
復制代碼




  1. <a href="forum.php?mod=viewthread&tid=$realtid&".(!empty($multipate_archive) ? "$multipate_archive&" : '')."extra=$extra&page=$thread[pages]">
復制代碼


替換為:

  1. <a href="thread-$realtid-$thread[pages]-1.html">
復制代碼



這樣,Discuz! X3.4 主題分類和分類信息帖子鏈接都會為偽靜態,有興趣的站長趕緊試試啊!



作者: pmxsd    時間: 2019-7-21 21:08
感謝老大分享

作者: sosoba    時間: 2019-7-23 18:50
感謝分享,學習了
作者: sosoba    時間: 2019-7-23 23:44
測試了一下,A類 主題分類偽靜態設置方法 親測有效

B類的 不行 設置修改后   分類信息 列表內的帖子還是 動態  列表分頁 也是動態


不過還是謝謝你的分享
作者: sosoba    時間: 2019-7-25 13:50
A、主題分類偽靜態設置方法  這個方法可以用,測試過了,生效了
非常感謝
B類的方法測試了下 不生效,不知道原因出在哪里

作者: allthebest    時間: 2019-7-25 18:46
sosoba 發表于 2019-7-25 13:50
A、主題分類偽靜態設置方法  這個方法可以用,測試過了,生效了
非常感謝
B類的方法測試了下 不生效,不知 ...

大概是第三方模版問題


作者: sosoba    時間: 2019-7-26 13:39
allthebest 發表于 2019-7-25 18:46
大概是第三方模版問題

有這個可能 我還在測試 不過感謝你的教程,非常棒
作者: 青蘋果    時間: 2020-1-9 07:10
感謝大佬分享
作者: zhsyn    時間: 2020-1-9 14:44
學習了,很好的分享
作者: yehui2512    時間: 2020-9-14 20:29
學習了,很好的分享
作者: 天使情歌洛莉    時間: 2021-1-20 11:32
感謝樓主分享這么好的方案,但是我遇到了以下問題

下載的Discuz! X3.4 R20200818 UTF-8版本
近期新安裝的論壇程序什么也沒有改動也沒有新模板
檢索字段跟樓主的不一樣出入大,尤其是B方案,不吻合,且前段檢索有2段吻合后面不一樣不知道如何修改
強行修改后報錯無法訪問

A方案也有出入,偽靜態規則
.htaccess 偽靜態規則 請在RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1下面增加:

沒有這一段與吻合的

問題應該是出自官方修改了文件代碼,希望樓主能下載看下新文件是不是3.4改動了出個新的
作者: gzwnzss    時間: 2021-1-20 22:54
DZ3.4親測,有些地方找不到。可以加QQ4175455有償幫忙解決嗎?
作者: 技術控    時間: 2021-2-5 11:32
關于主題分類偽靜態設置,有兩個問題請教一下:

1.第三步中3.主題類別前綴【只顯示文字】,2個地方需要修改,forum_forumdisplay.php文件中,沒有找到需要修改的這段代碼。
(, 下載次數: 29)
2.模板目錄viewthread.htm,除了默認模板forum目錄下的這個文件,第三方模板forum目錄下的viewthread.php這個文件也有一段相同的代碼,也需要修改嗎?

(, 下載次數: 26)





作者: allthebest    時間: 2021-2-5 21:00
技術控 發表于 2021-2-5 02:32
關于主題分類偽靜態設置,有兩個問題請教一下:

1.第三步中3.主題類別前綴【只顯示文字】,2個地方需要修 ...

若用第三方模板,先備份后,再修改。

程序查找不到,不用改。
作者: gzwnzss    時間: 2021-2-12 21:47
source\module\forum\forum_forumdisplay.php
X3.4這段代碼沒找到:
  1. forum.php?mod=forumdisplay&fid='.$_G['fid'].'&filter=typeid&typeid='.$thread['typeid'].'
復制代碼



作者: allthebest    時間: 2021-2-13 00:41
gzwnzss 發表于 2021-2-12 12:47
source\module\forum\forum_forumdisplay.php
X3.4這段代碼沒找到:

程序查找不到,說明更新已修正,代碼或許不同,不用再改。
作者: gongls    時間: 2021-3-17 12:24
太牛了!!
請問B分類信息列表內的帖子設置偽靜態的偽靜態規則呢
作者: y2j423633    時間: 2021-3-18 09:55
收藏一個支持一下
作者: c020109703    時間: 2021-12-24 00:09
forum_forumdisplay.php字段不匹配的原因找到了

樓主提供的地址中“&”符號的表達在最新版中實際變成了“&amp;



對比一下
樓主的:forum.php?mod=forumdisplay&fid='.$_G['fid'].'&filter=typeid&typeid='.$thread['typeid'].'

新版的:forum.php?mod=forumdisplay&fid='.$_G['fid'].'&amp;filter=typeid&amp;typeid='.$thread['typeid'].'
改成最新版的表達在查找就能找到了,確實是2處


作者: tianxiang    時間: 2022-2-22 16:46
寶塔的面板怎么弄這個偽靜態規則了?




歡迎光臨 Discuz! 官方交流社區 (http://www.9999xn.com/) Powered by Discuz! W1.0