本次开发基于Discuz X3,如果是其他版本的程序,需要各位自己验证一下。
Discuz后台的伪静态设置,不包含门户模块的伪静态设置,应该是考虑到频道页面的URL变化多样性,下面我们就一步一步学习将门户频道支持伪静态。
一、加上语言包中的记录
根目录下:source\\language\\lang_admincp.php
,找到 setting_seo_rewritestatus_portal_article
这一行,大概在1500行左右,搜索一下吧。
在这句代码的下方加入
\'setting_seo_rewritestatus_portal_list\' => \'门户频道页\',
二、后台加上设置项
根目录下:source\\function\\function_admincp.php
,找到rewritedata函数,在if语句的,两个大括号中,加上下面两段程序。
上面一段加上
if (in_array(\'portal_list\', $_G[\'setting\'][\'rewritestatus\'])) { $data[\'search\'][\'portal_list\'] = \"/\" . $_G[\'domain\'][\'pregxprw\'][\'portal\'] . \"\\?mod\\=list&(amp;)?catid\\=(\\d+)(&page\\=(\\d+))?\\\"([^\\>]*)\\>/e\"; $data[\'replace\'][\'portal_list\'] = \"rewriteoutput(\'portal_list\', 0, \'\\\\1\', \'\\\\3\', \'\\\\5\', \'\\\\6\')\"; }
下面一段加上
$data[\'rulesearch\'][\'portal_list\'] = \'list-{catid}-{page}.html\'; $data[\'rulereplace\'][\'portal_list\'] = \'portal.php?mod=list&catid={catid}&page={page}\'; $data[\'rulevars\'][\'portal_list\'][\'{catid}\'] = \'([0-9]+)\'; $data[\'rulevars\'][\'portal_list\'][\'{page}\'] = \'([0-9]+)\';
三、兼容栏目页URL地址设置
找到文件:
根目录:php\\source\\function\\function_core.php
这个文件中找到:函数rewriteoutput
在一串的if … else if中加上一段
elseif ($type == \'portal_list\') { list(,,, $id, $page, $extra) = func_get_args(); $r = array( \'{catid}\' => $id, \'{page}\' => $page ? $page : 1, ); }
保存后,就完成了本次开发,也给门户页面添加了伪静态功能
阅读全文
原文链接:https://xdyl.club/1846,转载请注明出处~~~