discuz

推荐列表 站点导航

当前位置:首页 > 建站教程 > discuz >

discuzx3.4文章进行全文检索的实现方法

来源:网络整理  作者:网络  发布时间:2020-12-11 13:41
搜索门户中的文章,并不是按这个走的,而且利用sphinx这个啊,要么只能分中文要么只能分英文(学艺不精没细了解...

代码如下:
网站目录\source\class\table\table_portal_article_content.php

搜索门户中的文章,并不是按这个走的,而且利用sphinx这个啊,要么只能分中文要么只能分英文(学艺不精没细了解啊,个人测试是这样的)。


代码如下:
3.打开

class table_portal_article_content extends discuz_table


{


上面添加那个方法才能用$query = C::t(‘portal_article_content’)->fetch_all_by_sql。
if($num==0){ list($srchtxt, $srchtxtsql) = searchkey($keyword, "content LIKE '%{text}%'", true); $query = C::t('portal_article_content')->fetch_all_by_sql(' 1 '.$srchtxtsql, 'ORDER BY aid DESC ', 0, $_G['setting']['search']['portal']['maxsearchresults']); foreach($query as $article) { $ids .= ','.$article['aid']; $num++; } }  

搜索
在其后添加如下代码:
上面代码的意思是,如果搜标题没搜到,那就用like来搜文章的内容。 代码如下:

变为:
class table_portal_article_content extends discuz_table { public function fetch_all_by_sql($where, $order = '', $start = 0, $limit = 0, $count = 0, $alias = '') { $where = $where && !is_array($where) ? " WHERE $where" : ''; if(is_array($order)) { $order = ''; } if($count) { return DB::result_first('SELECT count(*) FROM '.DB::table($this->_table).' %i %i %i '.DB::limit($start, $limit), array($alias, $where, $order)); } return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' %i %i %i '.DB::limit($start, $limit), array($alias, $where, $order)); }  




</p> <p> foreach($query as $article) { $ids .= ','.$article['aid']; $num++; }  

网站目录\source\module\search\search_portal.php
代码如下:




public function fetch_all_by_sql($where, $order = '', $start = 0, $limit = 0, $count = 0, $alias = '') { $where = $where && !is_array($where) ? " WHERE $where" : ''; if(is_array($order)) { $order = ''; } if($count) { return DB::result_first('SELECT count(*) FROM '.DB::table($this->_table).' %i %i %i '.DB::limit($start, $limit), array($alias, $where, $order)); } return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' %i %i %i '.DB::limit($start, $limit), array($alias, $where, $order)); }  

1.用notepad++或其他文本编辑器打开下述文件
2.在下面的


代码如下:
后添加

相关热词: discuz 方法

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://www.juheyunku.com/jz/discuz/2569.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

discuzx3.4文章进行全文检索的实现方法

2020-12-11 编辑:网络


代码如下:
网站目录\source\class\table\table_portal_article_content.php

搜索门户中的文章,并不是按这个走的,而且利用sphinx这个啊,要么只能分中文要么只能分英文(学艺不精没细了解啊,个人测试是这样的)。


代码如下:
3.打开

class table_portal_article_content extends discuz_table


{


上面添加那个方法才能用$query = C::t(‘portal_article_content’)->fetch_all_by_sql。
if($num==0){ list($srchtxt, $srchtxtsql) = searchkey($keyword, "content LIKE '%{text}%'", true); $query = C::t('portal_article_content')->fetch_all_by_sql(' 1 '.$srchtxtsql, 'ORDER BY aid DESC ', 0, $_G['setting']['search']['portal']['maxsearchresults']); foreach($query as $article) { $ids .= ','.$article['aid']; $num++; } }  

搜索
在其后添加如下代码:
上面代码的意思是,如果搜标题没搜到,那就用like来搜文章的内容。 代码如下:

变为:
class table_portal_article_content extends discuz_table { public function fetch_all_by_sql($where, $order = '', $start = 0, $limit = 0, $count = 0, $alias = '') { $where = $where && !is_array($where) ? " WHERE $where" : ''; if(is_array($order)) { $order = ''; } if($count) { return DB::result_first('SELECT count(*) FROM '.DB::table($this->_table).' %i %i %i '.DB::limit($start, $limit), array($alias, $where, $order)); } return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' %i %i %i '.DB::limit($start, $limit), array($alias, $where, $order)); }  




</p> <p> foreach($query as $article) { $ids .= ','.$article['aid']; $num++; }  

网站目录\source\module\search\search_portal.php
代码如下:




public function fetch_all_by_sql($where, $order = '', $start = 0, $limit = 0, $count = 0, $alias = '') { $where = $where && !is_array($where) ? " WHERE $where" : ''; if(is_array($order)) { $order = ''; } if($count) { return DB::result_first('SELECT count(*) FROM '.DB::table($this->_table).' %i %i %i '.DB::limit($start, $limit), array($alias, $where, $order)); } return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' %i %i %i '.DB::limit($start, $limit), array($alias, $where, $order)); }  

1.用notepad++或其他文本编辑器打开下述文件
2.在下面的


代码如下:
后添加

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://www.juheyunku.com/jz/discuz/2569.shtml

相关文章

风云图片

推荐阅读

返回discuz频道首页