Beispiel #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Show::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'catalog_id' => $this->catalog_id, 'user_id' => $this->user_id, 'click' => $this->click, 'status' => $this->status, 'create_time' => $this->create_time, 'update_time' => $this->update_time]);
     $query->andFilterWhere(['like', 'author', $this->author])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'brief', $this->brief])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'seo_title', $this->seo_title])->andFilterWhere(['like', 'seo_keywords', $this->seo_keywords])->andFilterWhere(['like', 'seo_description', $this->seo_description])->andFilterWhere(['like', 'banner', $this->banner])->andFilterWhere(['like', 'template', $this->template])->andFilterWhere(['like', 'redirect_url', $this->redirect_url]);
     return $dataProvider;
 }
Beispiel #2
0
 public function actionList()
 {
     $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     if (0 >= $id) {
         $this->redirect(Yii::$app->homeUrl);
     }
     $catalog = Catalog::findOne(['id' => $id]);
     $templatePage = $catalog->template_list ? $catalog->template_list : 'list';
     $portlet = Catalog::getCatalogSub2($id, Catalog::find()->all());
     $portletTitle = Catalog::findOne(['id' => Catalog::getRootCatalogId($id, Catalog::find()->all())])->title;
     $ids = Catalog::getCatalogIdStr($id, Catalog::find()->all());
     echo $ids;
     $query = Show::find()->where("catalog_id in ({$ids})");
     $pagination = new Pagination(['defaultPageSize' => 20, 'totalCount' => $query->count()]);
     $show = $query->orderBy('create_time desc')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render($templatePage, ['catalog' => $catalog, 'show' => $show, 'portlet' => $portlet, 'portletTitle' => $portletTitle, 'pagination' => $pagination]);
 }