大家都知道搜索页面不支持标签,但是对于需要完善搜索功能的站长需要特殊功能。如何让帝国CMS搜索页面支持标签呢?
头部引用
修改 e/search/result/index.php
源代码:
<?php
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../data/dbcache/class.php");
require("../../class/q_functions.php");
require "../".LoadLang("pub/fun.php");源代码修改为:
<?php
require("../../class/connect.php");
require("../../class/db_sql.php");
require("../../class/functions.php");
require("../../class/t_functions.php");
require("../../data/dbcache/class.php");
require "../".LoadLang("pub/fun.php");
查找 //替换公共模板变量 在上面增加: //页面支持标签
$tempr[temptext]=DtNewsBq('list'.$tempid,$tempr[temptext],0);
这样搜索页面就可以支持标签使用 。
解决方案
此方法有BUG会缓存标签,造成使用两个搜索模板的时候切换不成功。解决方法如下:
找到/e/class/functions.php搜索 //标签替换4在这个标签的后面增加一个标签
实例代码如下:
//标签替换
function DtNewsBq2($classid,$indextext,$ecms=0){
global $empire,$dbtbpre,$public_r,$emod_r,$class_r,$class_zr,$fun_r,$navclassid,$navinfor,$class_tr,$level_r,$etable_r;
$cachetime=0;
$file=ECMS_PATH.'e/data/tmp/list'.$classid.'.php';
if($cachetime&&file_exists($file)){
$filetime=filemtime($file);
$string=RepExeCode($string);//解析代码
return $string;
}
$indextext=stripSlashes($indextext);
$indextext=ReplaceTempvar($indextext);//替换全局模板变量
//替换标签
$indextext=DoRepEcmsLoopBq($indextext);
$indextext=RepBq($indextext);
//写文件
WriteFiletext($file,AddCheckViewTempCode().$indextext);
//读取文件内容
ob_start();
include($file);
$string=ob_get_contents();
ob_end_clean();
$string=RepExeCode($string);//解析代码
return $string;
}
/e/search/result/index.php查找 //替换公共模板变量 此处修改为:
//页面支持标签
$tempr[temptext]=DtNewsBq2('list'.$tempid,$tempr[temptext],0);//xuan
这样即可消除此BUG,虽然不完善,但是足够使用了。
按字母顺序浏览:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
→我们致力于为广大网民解决所遇到的各种电脑技术问题 如果您认为本词条还有待完善,请 编辑词条