|
|
|
@admin:回复 #3 确实因为输出搜索结果还需要得出页数会第一句SQL所以就省略了 我想到一个办法不执行sql {hook a_search_index_2}
$Thread = M("Thread");
$data=array();
$data = $Thread->search_list($pageid,$this->conf['searchlist'],$key);
$Thread->format($data);
{hook a_search_index_3}
//这部分
$count = $this->_count['thread'];
$count = (!$count)?1:$count;
$page_count = ($count % $this->conf['searchlist'] != 0)?(intval($count/$this->conf['searchlist'])+1) : intval($count/$this->conf['searchlist']);
//修改
$t=$key;
foreach ($data as &$v) {
$v['title'] = str_replace($key,'<font color="red">'.$key.'</font>',$v['title']);
}
{hook a_search_index_v}
$this->v("pageid",$pageid);
$this->v("page_count",$page_count);
$this->v("data",$data);
$this->v("top_list",array());
$this->display('search_index');改成 {hook a_search_index_2}
$Thread = M("Thread");
$data=array();
$data = $Thread->search_list($pageid,$this->conf['searchlist'],$key);
$Thread->format($data);
{hook a_search_index_3}
//这部分
$count = count($data);
if($count<$this->conf['searchlist'])
$page_count = $pageid;//因为view文件里是要判断他们相等才不让点
else
$page_count = $pageid+1;//永远不相等
//修改
$t=$key;
foreach ($data as &$v) {
$v['title'] = str_replace($key,'<font color="red">'.$key.'</font>',$v['title']);
}
{hook a_search_index_v}
$this->v("pageid",$pageid);
$this->v("page_count",$page_count);
$this->v("data",$data);
$this->v("top_list",array());
$this->display('search_index');唯一的缺点就是当 $count的值和$this->conf['searchlist']一样时,也是会让点下一页的 |
|
加载更多