where(['id'=>$cate_id])->getField('name'); $key_words = D('Keywords')->where(['id'=>$keyword_id])->getField('name'); $this->key_words = $key_words; if(!empty($key_words)){ $this->meta_title=$key_words; }else{ $this->meta_title=$cate_name; //分享标题 $this->share_title=$cate_name; } $this->cate_name = $cate_name ; $map = ['status'=>DBCont::YES_BOOL_STATUS]; $news_cate = D('NewsCate')->where($map)->order('sort asc,id desc')->select(); $this->news_cate = $news_cate; $this->display(); } public function detail() { $id=I('get.id'); $map['status'] = DBCont::YES_BOOL_STATUS; $map['id'] = $id; $detail = D('News')->where($map)->find(); D('News')->where(['id'=>$id])->setField('click_time',$detail['click_time']+1); $cate_res = explode(',',$detail['cate_id']); $keyword_res = explode(',',$detail['keywords_id']); //关键词的点击量+1 D('Keywords')->where(['id'=>['IN',$keyword_res]])->setInc('total_time',+1); $cate_name = D('NewsCate')->where(['id'=>['IN',$cate_res]])->getField('id,name',true); $keywords = D('Keywords')->where(['id'=>['IN',$keyword_res]])->getField('id,name',true); $cate_id=I('get.cate_id'); if(!empty($cate_id)){ $top_cate_name = D('NewsCate')->where(['id'=>$cate_id])->getField('name'); $this->meta_title = $detail['title'].' | '.$top_cate_name; }else{ $this->meta_title = $detail['title']; } $this->cate_name=$cate_name; $this->keywords=$keywords; $this->detail=$detail; //分享标题 $this->share_title=$detail['title']; $this->share_link=U('',['id'=>$id],true,true); $img=showFileUrl($detail['cover_id']); if (filter_var($img,FILTER_VALIDATE_URL)){ $this->share_img = $img; }else{ $this->share_img = HTTP_PROTOCOL.'://'.SITE_URL.$img; } $this->display(); } }