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来搜文章的内容。