国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > CMS > Discuz > 正文

discuzx3.4文章進行全文檢索的實現方法

2024-09-11 09:05:06
字體:
來源:轉載
供稿:網友
搜索門戶中的文章,并不是按這個走的,而且利用sphinx這個啊,要么只能分中文要么只能分英文(學藝不精沒細了解啊,個人測試是這樣的)。

1.用notepad++或其他文本編輯器打開下述文件

網站目錄/source/class/table/table_portal_article_content.php
2.在下面的

代碼如下:

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));}


變為:

代碼如下:

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));}


上面添加那個方法才能用$query = C::t(‘portal_article_content’)->fetch_all_by_sql。

3.打開

網站目錄/source/module/search/search_portal.php

搜索

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



在其后添加如下代碼:

代碼如下:

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來搜文章的內容。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 仁布县| 崇文区| 博白县| 潢川县| 怀化市| 阳朔县| 喜德县| 延吉市| 白水县| 独山县| 博兴县| 北流市| 扎赉特旗| 永宁县| 清水河县| 高陵县| 新民市| 扎囊县| 荥经县| 进贤县| 阳高县| 兴和县| 凌源市| 通许县| 历史| 松滋市| 涞源县| 满洲里市| 潮州市| 汉阴县| 镇远县| 临高县| 康马县| 赣榆县| 陵水| 淳化县| 怀仁县| 龙门县| 略阳县| 东丽区| 北安市|