首先准备好修改的模板文件:forumdisplay.htm、forumdisplay_list.htm,这两个文件都在 \template\default\forum 的目录下。
我们要先修改主题分类的:打开forumdisplay.htm的源代码:
默认主题一般在415行,当然如你的主题有修改过模板,以你的主题文件为准
<li><a href="forum.php?mod=forumdisplay&fid=$_G[fid]&filter=typeid&typeid=$id$forumdisplayadd[typeid]{if $_GET['archiveid']}&archiveid={$_GET['archiveid']}{/if}">修改为:
<li><a href="forumtype-$_G[fid]-$id-$page.html{if $_GET['archiveid']}&archiveid={$_GET['archiveid']}{/if}">接下来再打开forumdisplay_list.htm的源代码:
默认主题一般在162行,如你的主题有修改过模板,以你的主题文件为准找到:
<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>修改为:
<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}{/if} class="s xst">$thread[subject]</a>主题类别前缀【只显示文字】,2个地方需要修改
1、打开source\module\forum\forum_forumdisplay.php,查找
forum.php?mod=forumdisplay&fid='.$_G['fid'].'&filter=typeid&typeid='.$thread['typeid'].'替换为
forumtype-'.$_G['fid'].'-'.$thread['typeid'].'-1.html2、打开模板目录viewthread.htm,查找
forum.php?mod=forumdisplay&fid=$_G[fid]&filter=typeid&typeid=$_G[forum_thread][typeid]替换为
forumtype-$_G[fid]-{$_G[forum_thread][typeid]}-1.html最后我们要把主题分类的伪静态规则添加到相应文件中,规则如下(因为环境问题,只测试了.htaccess,其它请自行测试):
nginx .htaccess 伪静态规则
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^forumtype-(\w+)-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&filter=typeid&typeid=$2&page=$3&%1httpd.ini 伪静态规则
RewriteRule ^(.*)/forumtype-(\w+)-(\w+)-([0-9]+)\.html(\?(.*))*$ $1/forum\.php\?mod=forumdisplay&fid=$2&filter=typeid&typeid=$3&page=$4&$5Apache web.config 伪静态规则
<rule name="forum_forumtype"> <match url="^(.*/)*forumtype-(\w+)-(\w+)-([0-9]+).html\?*(.*)[ DISCUZ_CODE_2 ]quot; /> <action type="Rewrite" url="{R:1}/forum.php\?mod=forumdisplay&fid={R:2}&filter=typeid&typeid={R:3}&page={R:4}&{R:5}" /> </rule>http://www.17zyy.cn/newsSubject/news/10982
|
历史资源提醒--必看
该页面资源/教程来自原魔趣吧历史资源转移,因发布历史久远,部分资源/教程可能已失效或无法在最新版程序中安装使用!DZ资源建议在Discuz3.4及以下版本使用,PHP版本建议5.6。资源仅提供做代码研究学习使用!
因改版,部分贴内链接将无法正常跳转,如链接失效或未正常跳转,请利用站内搜索功能搜索资源名称获取对应资源!