欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

discuz

當前位置:主頁 > CMS教程 > discuz >

discuzx3.1文章進行全文檢索的實現(xiàn)方法

來源:本站原創(chuàng)|時間:2020-01-11|欄目:discuz|點擊: 次

首先說明啊,這個檢索是直接用like來弄的,所以,如果你的站數(shù)據(jù)量大,這樣很吃系統(tǒng),自己掂量著辦,我研究了下利用sphinx的,結果搞定了才發(fā)現(xiàn)這個只是針對論壇的帖子。搜索門戶中的文章,并不是按這個走的,而且利用sphinx這個啊,要么只能分中文要么只能分英文(學藝不精沒細了解啊,個人測試是這樣的)。而我目前碰到的要求是需要對文章也執(zhí)行l(wèi)ike。所以,經(jīng)過研究,類比了下搜索文章標題的功能,成功實現(xiàn)了discuzX3對門戶中的文章進行全文檢索的功能,以下操作方法discuz版本為20140101的X3.1。具體方法如下:

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

網(wǎng)站目錄\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));
}

變?yōu)椋?br />
復制代碼
代碼如下:

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.打開

網(wǎng)站目錄\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來搜文章的內(nèi)容。
保存后,更新下discuz的緩存,搜文章里的內(nèi)容試試,如果能搜到,OK,大功告成~

上一篇:DiscuzX沒有合法的文件被上傳的修復方法

欄    目:discuz

下一篇:Discuz x3.1頁面空白解決方法

本文標題:discuzx3.1文章進行全文檢索的實現(xiàn)方法

本文地址:http://mengdiqiu.com.cn/a1/discuz/12867.html

網(wǎng)頁制作CMS教程網(wǎng)絡編程軟件編程腳本語言數(shù)據(jù)庫服務器

如果侵犯了您的權利,請與我們聯(lián)系,我們將在24小時內(nèi)進行處理、任何非本站因素導致的法律后果,本站均不負任何責任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權所有