Exemplo n.º 1
0
 public function actionIndex($slug)
 {
     $category = CatalogCategories::find()->where(['slug' => $slug])->one();
     if (!$category) {
         throw new \yii\web\NotFoundHttpException(\Yii::t('app', 'Page not found'));
     }
     /*    $dataProvider = new \app\modules\catalog\components\CatalogDataProvider([
                'category_id' => $category->id,
                'pagination' => [
           //         'pageSize' => 1,
                ],
            ]);*/
     $cs = new CatalogSearch();
     // return $this->render('index',[ 'model' => $category, 'dataProvider' => $dataProvider ]);
     $searchModel = new CatalogSearch(['category_id' => $category->id]);
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     /*  return $this->render('/position/index', [
             'category' => $category,
             'searchModel' => $searchModel,
             'dataProvider' => $dataProvider,
         ]);*/
     $options = ['category' => $category, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider];
     if (Yii::$app->request->isPjax) {
         return $this->renderAjax('/position/index', $options);
     } else {
         return $this->render('/position/index', $options);
     }
 }
Exemplo n.º 2
0
 /**
  * Lists all Catalog models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new CatalogSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }