pid =0; $result =$model->getList([],'id,pid,name',2); $result = ArrayHelper::toArray($result); foreach($result as $k=>$v){ $model->pid =$v['id']; $arr =$model->getList([],'id,pid,name',1); $arr = ArrayHelper::toArray($arr); $result[$k]['child']=$arr; } return $this->render('index',['result'=>$result]); } //列表 public function actionList() { $model = new NewKnowledgelabel(); $model->pid =0; $result =$model->getList([],'id,pid,name',2); $result = ArrayHelper::toArray($result); foreach($result as $k=>$v){ $model->pid =$v['id']; $arr =$model->getList([],'id,pid,name',1); $arr = ArrayHelper::toArray($arr); $result[$k]['child']=$arr; } return $this->render('list',['result'=>$result]); } //获取数据 public function actionGetlist() { $model = new NewsKnowledge(); if(Yii::$app->request->get('id') != 0) { $model->label_id = Yii::$app->request->get('id'); } $knowData=$model->getMtitle(Yii::$app->request->get(),'pfg_news_knowledge.id,pfg_news_knowledge.abstract,pfg_news_knowledge.subject,pfg_news_knowledge.thumb,pfg_news_knowledge.abstract,pfg_news_knowledge.source,pfg_news_knowledge.clicks,pfg_news_knowledge.create_at,pfg_new_knowledgelabel.name',1); foreach($knowData as $k=>$v){ $knowData[$k]['thumb']=json_decode($v['thumb'],true); $knowData[$k]['create_at']=date("Y-m-d",$v['create_at']); } if(!empty($knowData)){ return Help::JsonCode(Help::SUCCESS,'成功',$knowData); } return Help::JsonCode(Help::ERROR,'失败'); } /*获取到导航*/ public function actionGetnav() { $model = new NewKnowledgelabel(); if(Yii::$app->request->get('id') != 0) { $model->pid = Yii::$app->request->get('id'); } $result =$model->getList([],'id,pid,name',1); $result = ArrayHelper::toArray($result); /* foreach($result as $k=>$v){ $model->pid =$v['id']; $arr =$model->getList([],'id,pid,name',1); $arr = ArrayHelper::toArray($arr); $result[$k]['child']=$arr; }*/ if(!empty($result)){ return Help::JsonCode(Help::SUCCESS,'成功',$result); } return Help::JsonCode(Help::ERROR,'失败'); } public function actionDetails() { $input = Yii::$app->request->get(); $model= new NewsKnowledge(); $row = $model->NewsKnowledgeDetails($input); if(empty($row)) return $this->goBack(); $newsModel= new News(); $newsClick = $newsModel->Clicks(10); $hotHouse = $this->HotHouse(); $prev=$this->prev($input); $next=$this->next($input); return $this->render('details',['row'=>$row,'newsClick'=>$newsClick,'hotHouse'=>$hotHouse,'prev'=>$prev,'next'=>$next]); } /*上一篇*/ public function prev($input) { $model= new NewsKnowledge(); $input['mark']='>'; return $model->getPage($input); } /*下一篇*/ public function next($input) { $model= new NewsKnowledge(); $input['mark']='<'; return $model->getPage($input); } private function HotHouse() { $model = new PushHousesale(); $model->type = 1; if(Yii::$app->hostserver->hostId != 0) { $model->city = Yii::$app->hostserver->hostId; } $rows = $model->Homegetlist(4); if($rows != null) { $zhuti = new \frontend\server\HouseServer(); foreach ($rows as &$val) { $val['characteristic'] = $zhuti->Subject( json_decode($val['characteristic']),2); $val['thumb'] = Yii::$app->params['httpImg']['hosts'].Yii::$app->params['httpImg']['houses']. $val['thumb']; } return $rows; } } public function actionTools() { echo 123456; exit; //return $this->render('tools'); } }