public function actionOffers($catgry = 0) { $category = 'Sve ponude'; $request = \Yii::$app->request; $descript = $request->post('descript') != null ? $request->post('descript') : ''; $query = Offer::find()->where(['like', 'descript', $descript])->orderBy('priority'); if ($catgry > 0) { $query = Offer::find()->where(['catgry' => $catgry])->andWhere(['like', 'descript', $descript])->orderBy('priority'); $category = Catgry::findOne($catgry); $category = $category->name; } $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 9]]); return $this->render('offers', ['dataProvider' => $dataProvider, 'category' => $category]); }
<div class="col-sm-4"> <div class="companyinfo"> <img class="img-responsive" src="<?php echo Url::base(); ?> /img/home/baner.png" alt="gde za vikend logo"> </div> </div> <div class="col-sm-8"> <div class="row"> <div class="col-sm-3"> <div class="single-widget companyinfo"> <h2>Kategorije</h2> <?php $categories = Catgry::find()->all(); foreach ($categories as $category) { ?> <ul class="nav nav-pills nav-stacked"> <li><a href="<?php echo Url::to(['site/offers', 'catgry' => $category->id]); ?> "><?php echo $category->name; ?> </a></li> </ul> <?php