Example #1
0
 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();
 }
Example #2
0
 /**
  * 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;
 }
Example #3
0
 /**
  * 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;
 }
Example #4
0
 /**
  * Finds the Category model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Category the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Category::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #5
0
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 
Example #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategories()
 {
     return $this->hasMany(Category::className(), ['parent_id' => 'id']);
 }
Example #7
0
File: index.php Project: apuc/admin
?>

    <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();
Example #8
0
 public function getCategories()
 {
     return $this->hasMany(Category::className(), ['id' => 'category_id'])->viaTable('brand_category', ['brand_id' => 'id']);
 }
Example #9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategoryId()
 {
     return $this->hasOne(Category::className(), ['id' => 'category_id']);
 }