public function search($params)
 {
     $query = PageMetaTag::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->request->cookies->getValue('_grid_page_size', 20)], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['page_meta_tag.id' => $this->id, 'page_meta_tag.created_at' => $this->created_at, 'page_meta_tag.updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'page_meta_tag.url', $this->url])->andFilterWhere(['like', 'page_meta_tag.title', $this->title])->andFilterWhere(['like', 'page_meta_tag.keywords', $this->keywords])->andFilterWhere(['like', 'page_meta_tag.description', $this->description]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Register keywords, description and set title for page
  *
  * @param View $view
  */
 protected static function registerMetaTagsByUrl($view)
 {
     $metaTag = PageMetaTag::find()->andWhere(['url' => Yii::$app->request->absoluteUrl])->asArray()->one();
     if ($metaTag['title']) {
         $view->title = $metaTag['title'];
     }
     if ($metaTag['keywords']) {
         $view->registerMetaTag(['name' => 'keywords', 'content' => $metaTag['keywords']], 'keywords');
     }
     if ($metaTag['description']) {
         $view->registerMetaTag(['name' => 'description', 'content' => $metaTag['description']], 'description');
     }
 }