Beispiel #1
0
 public function generatePageData()
 {
     $where = ['view' => $this->route];
     $where['action_params'] = json_encode($this->actionParams);
     $page = SeoPages::find()->where($where)->with('meta')->one();
     if ($this->trackViews && $page == null) {
         $page = new SeoPages();
         $page->view = $this->route;
         $page->action_params = $this->actionParams;
         $page->save();
     } else {
         $this->setMetaTags($page->meta);
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SeoPages::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'view', $this->view])->andFilterWhere(['like', 'action_params', $this->action_params]);
     return $dataProvider;
 }
 /**
  * Finds the SeoPages model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return SeoPages the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = SeoPages::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 protected function findPagesArray()
 {
     $urlManager = $this->module->urlManager;
     $pagesModel = SeoPages::find()->all();
     $pageArray = [];
     foreach ($pagesModel as $value) {
         $params = [$value->view];
         $params = ArrayHelper::merge($params, $value->action_params);
         $pageArray[$value->id] = Yii::$app->{$urlManager}->createUrl($params);
     }
     return $pageArray;
 }
Beispiel #5
0
 public function getPage()
 {
     return $this->hasOne(SeoPages::className(), ['id' => 'page_id']);
 }