public function actionIndex() { //$page = Pages::find()->where(['id' => $_GET['p']])->one(); $cat = \backend\modules\category\models\Category::find()->where(['id' => $_GET['c']])->one(); //$content = $this->getBlocks($cat); //$con = $this->render('index', ['content' => $content, 'page' => $cat]); Template::get_header($cat); $this->getBlocks($cat); Template::get_footer(); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Category::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'count_product' => $this->count_product, 'blokc_id' => $this->blokc_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'images', $this->images])->andFilterWhere(['like', 'hint', $this->hint])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'h1', $this->h1])->andFilterWhere(['like', 'keywords', $this->keywords]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Category::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
use yii\widgets\Menu; /* @var $this yii\web\View */ /* @var $model backend\modules\category\models\Category */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="well form"> <?php $form = ActiveForm::begin(); ?> <div class="row"> <div class="col-sm-4"> <?php echo $form->field($model, 'parent_id')->dropDownList(ArrayHelper::map(Category::find()->all(), 'id', 'name')); ?> </div> <div class="col-sm-4"> <?php echo $form->field($model, 'slug')->textInput(['maxlength' => true]); ?> </div> <div class="col-sm-4"> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> </div> </div> <?php
?> <p> <?php echo Html::a('Создать', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'name', 'format' => 'html', 'value' => function ($model) { return "<div>{$model->name}</div>"; }], ['class' => DataColumn::className(), 'header' => 'Раздел', 'format' => 'html', 'value' => function ($model) { $cat = \common\models\BlindCatid::find()->where(['id_blind' => $model->id])->all(); $title = '<ul>'; foreach ($cat as $c) { $catObj = \backend\modules\category\models\Category::find()->where(['id' => $c->id_cat])->one(); $title .= "<li>" . $catObj->name . "</li>"; } $title .= "</ul>"; return $title; }], ['attribute' => 'status', 'format' => 'text', 'value' => function ($model) { if ($model->status == 1) { return 'Опубликовано'; } else { return 'Не опубликовано'; } }], ['class' => DataColumn::className(), 'header' => 'Цена', 'format' => 'html', 'value' => function ($model) { $page2BlindID = PageToBlind::find()->where(['id_blind' => $model->id])->all(); $supIds = []; foreach ($page2BlindID as $page) { $s = PageItem::find()->where(['id_page' => $page->id_pages, 'item_type' => 'materials'])->all();