public function actionAdmin()
 {
     $this->layout = 'admin';
     $searchModel = new NewsSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('admin', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Exemple #2
0
 /**
  * Lists all News models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new NewsSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Exemple #3
0
 public function actionClientNewsList($cat)
 {
     //cat 新闻类别 1 行业新闻, 2 公司动态
     $searchModel = new NewsSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $cat);
     return $this->render('clientNewsList', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Exemple #4
0
 /**
  * Finds the News model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return News the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (!\Yii::$app->user->isGuest) {
         if (($model = News::findOne($id)) !== null) {
             return $model;
         } else {
             throw new NotFoundHttpException('The requested page does not exist.');
         }
     }
     $model = new LoginForm();
     if ($model->load(\Yii::$app->request->post()) && $model->login()) {
         $searchModel = new NewsSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
     } else {
         return $this->render('login', ['model' => $model]);
     }
 }