之前做过一个搜索功能,是直接调用PHPcms v9本身的全文搜索,通过自定义typeid来定义自己所要搜索的栏目,无意间在网上发现一个自定义catid来搜索的,感觉十分不错。
一、 修改phpcms/model/content_model.class.php
//112行附近
$this->search_api($id,$inputinfo);
修改为:
$this->search_api($id,$systeminfo['catid'],$inputinfo);
//public function search_api这个函数进行修改
public function search_api($id = 0,$catid, $data = array(), $action = 'update'){
$type_arr = getcache('search_model_'.$this->siteid,'search');
$typeid = $type_arr[$this->modelid]['typeid'];
if($action == 'update'){
$fulltext_array = getcache('model_field_'.$this->modelid,'model');
foreach($fulltext_array AS $key=>$value){
if($value['isfulltext']) {
$fulltextcontent .= $data['system'][$key] ? $data['system'][$key] : $data['model'][$key];
}
}
$this->search_db->update_search($typeid ,$id, $fulltextcontent,addslashes($data['system']['title']).' '.addslashes($data