public function actionIndex($type, $catid = 0)
 {
     $query = Fragment::find()->where(['type' => $type]);
     if ($catid > 0) {
         $query->andWhere(['category_id' => $catid]);
     }
     $locals = LuLu::getPagedRows($query, ['order' => 'id desc']);
     $locals['type'] = $type;
     return $this->render('index', $locals);
 }
Example #2
0
 public function search($params)
 {
     $query = Fragment::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'type' => $this->type, 'sort_num' => $this->sort_num]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }