Ejemplo n.º 1
0
 /**
  * 网站首页
  * 无限加载
  * @return string
  */
 public function actionIndex()
 {
     //翻页 分类  标签(暂时不做标签)
     $params = \Yii::$app->request->queryParams;
     //分类
     $condition = array();
     if (isset($params['term'])) {
         $term = Term::findOne(['slug' => $params['term']]);
         $term ? $params['PostSearch']['term_id'] = $term->id : '';
     }
     $postSearch = new PostSearch();
     $dataProvider = $postSearch->search($params, $condition);
     return $this->render('index', ['postSearch' => $postSearch, 'dataProvider' => $dataProvider]);
 }
Ejemplo n.º 2
0
 /**
  * Finds the Term model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Term the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Term::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }