public function actionBrandView($lang = null, $alias) { $brand = Brand::find()->lang($lang)->andWhere(['alias' => $alias])->one(); if (!$brand) { throw new HttpException(404, 'Брэнд не найден'); } if (\Yii::$app->request->isAjax) { return $this->renderAjax('brandView', ['brand' => $brand]); } return $this->render('brandView', ['brand' => $brand]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Brand::find()->lang(); $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, 'position' => $this->position]); $query->andFilterWhere(['like', 'lang', $this->lang])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'descriptionShort', $this->descriptionShort])->andFilterWhere(['like', 'alias', $this->alias]); return $dataProvider; }
<?php /** * Created by PhpStorm. * User: ivphpan * Date: 19.01.16 * Time: 18:06 */ /** @var $brandList \app\modules\catalog\models\Brand*/ $brandList = \app\modules\catalog\models\Brand::find()->lang()->all(); ?> <div class="brand-logo bounceInUp animated"> <div class="container"> <div class="slider-items-products"> <div id="brand-logo-slider" class="product-flexslider hidden-buttons"> <div class="slider-items slider-width-col6"> <?php foreach ($brandList as $brand) { ?> <!-- Item --> <div class="item"> <a href="<?php echo $brand->url; ?> "><img src="<?php echo $brand->imageSrc('130x50', \yii\image\drivers\Image::AUTO, 1); ?> " alt="Image"></a> </div> <!-- End Item -->