疆飞
.NET永远年轻,永远热泪盈眶...
展开边栏 收起边栏
正确的使用phpcms 搜索,可解决搜索为空的问题
问题的前提是你先正确的开启了并正确设置了搜索功能,在后台设置,如果不会可以自行参考官方的使用文档,如果正确开启了还不行就看下面吧
1.找到 phpcms/modules/search/index.php 文件,打开并编辑。
2.查找代码:
//如果分词结果为空
if(!empty($segment_q)) {
$sql = "`siteid`= '$siteid' AND `typeid` = '$typeid' $sql_time AND MATCH (`data`) AGAINST ('$segment_q' IN BOOLEAN MODE)";
} else {
$sql = "`siteid`= '$siteid' AND `typeid` = '$typeid' $sql_time AND `data` like '%$q%'";
}
$result = $this->db->listinfo($sql, 'searchid DESC', $page, 10);
替换为:
//如果分词结果为空
if(!empty($segment_q)) {
$sql = "`siteid`= '$siteid' AND `typeid` = '$typeid' $sql_time AND MATCH (`data`) AGAINST ('$segment_q' IN BOOLEAN MODE)";
} else {
$sql = "`siteid`= '$siteid' AND `typeid` = '$typeid' $sql_time AND `data` like '%$q%'";
}
$sql = "`siteid`= '$siteid' AND `typeid` = '$typeid' $sql_time AND `data` like '%$q%' ";
$result = $this->db->listinfo($sql, 'searchid DESC', $page, 10);
仔细看,实际上就是加了一行
$sql = "`siteid`= '$siteid' AND `typeid` = '$typeid' $sql_time AND `data` like '%$q%' ";
然后搞定。
文章搜索
联系疆飞
- QQ932557101
- emailmail@jiangfei.net
- weibo@疆飞 (@jiangfei1006)
- twitter@疆飞 (@jiangfei1006)
PS:没事不要瞎联系,除非你想请我吃饭...
热门标签更多
Copyright © 2008-. JiangFei.net all rights reserved
苏公网安备32048202001026号苏ICP备18062911号