public function actionView($alias) { $model = Services::find()->where(['alias' => $alias])->one(); if (!$model) { throw new NotFoundHttpException(\Yii::t('backend', 'Page not found')); } return $this->render('view', ['model' => $model]); }
/** * Finds the Services model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Services the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Services::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Services::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); $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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'service_title', $this->service_title])->andFilterWhere(['like', 'img', $this->img])->andFilterWhere(['like', 'service_content', $this->service_content])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_description', $this->meta_description])->andFilterWhere(['like', 'alias', $this->alias]); return $dataProvider; }
echo Html::decode($model->page_content); ?> </div> </div> </div> </section> <div class="section portfolio-section"> <div class="container"> <div class="row isotope-container"> <?php foreach (\backend\modules\services\models\Services::find()->orderBy('id DESC')->limit(9)->all() as $data) { ?> <div class="col-md-4"> <div class="entry"> <div class="entry-media"> <?php echo HTML::a(HTML::img('/images/' . $data->img, ['class' => 'img-responsive']), ['services/view', 'alias' => $data->alias]); ?> </div> <div class="entry-top"> <h3 class="entry-title"><?php echo HTML::a($data->service_title, ['services/view', 'alias' => $data->alias]); ?> </h3> </div> </div>