搜索关键词字段是:$name
这是函数代码:
public function tag(){
$HOME_PUBLIC = C('HOME_PUBLIC');
$this->assign('HOME_PUBLIC',$HOME_PUBLIC);
$YICMS_PUBLIC = C('YICMS_PUBLIC');
$this->assign('YICMS_PUBLIC',$YICMS_PUBLIC);
$data = M('About');
$about = $data->find();
$this->assign('about',$about);
$name = $_REQUEST['name'];
if($name !== iconv('UTF-8','UTF-8',iconv('UTF-8','UTF-8',$name))) $name = iconv('GBK','UTF-8',$name);
import("@.ORG.Page");
$count = M('News')->where("state = 1 AND content like '%$name%'")->count('id');
$p = new Page ($count,20);
$list = M()->Table(array(C('DB_PREFIX').'news'=>'news',C('DB_PREFIX').'user'=>'user'))->where("news.state = 1 AND news.uid = user.uid AND news.content like '%$name%'")->order('news.time DESC')->limit($p->firstRow.','.$p->listRows)->select();
$p->setConfig('theme','%first% %prePage% %li
$page = $p->show();
if(is_array($list)){
foreach($list as $key=>$value){
if(C('ISHTML')){
$pid = $value['pid'];
$nav = M('Nav')->where("id = $pid")->find();
$nav['dir'] = rtrim($nav['dir'],'/');
$conname = str_replace('{id}',$value['id'],$nav['conname']);
$conname = str_replace('{Y}',date('Y',$news['time']),$conname);
$list[$key]['url']= C('URL').'/'.$nav['dir'].'/'.$conname;
}else{
$list[$key]['url']= C('URL').'/index.php/Index/news/id/'.$value['id'];
}
$list[$key]['spic'] = C('URL').'/Public/news/s_'.$value['pic'];
$list[$key]['mpic'] = C('URL').'/Public/news/m_'.$value['pic'];
if(!empty($value['tag'])) $list[$key]['tag'] = explode(' ',$value['tag']);
}
$this->assign('list',$list);
$this->assign('page',$page);
$this->assign('count',$count);
}else{
$this->assign('count',0);
}
$this->assign('name',$name);
$data = M('Config');
$config = $data->find();
$config['ti
if(stripos($config['ti
$this->assign('config',$config);
$tagList = M('Tag')->order('taxis ASC,id DESC')->select();
$this->assign('tagList',$tagList);
$this->display();
}
最佳答案