diff --git a/widgets/Seo.php b/widgets/Seo.php index 0d50e71..93f8841 100755 --- a/widgets/Seo.php +++ b/widgets/Seo.php @@ -68,7 +68,7 @@ class Seo extends Widget if(empty($filter) && empty($sort) && empty($paginate) ){ - return $this->prepareString($this->selectSeoData(self::SEO_TEXT,$filter)); + return $this->prepareString($this->selectSeoData(self::SEO_TEXT,$filter,$priority)); } else { @@ -101,7 +101,7 @@ class Seo extends Widget $filter = \Yii::$app->request->get('filters', []); - $default = $this->selectSeoData(self::H1, $filter); + $default = $this->selectSeoData(self::H1, $filter,$priority); if ($default != $this->{self::H1}) { @@ -122,10 +122,10 @@ class Seo extends Widget $filter = \Yii::$app->request->get('filters', []); - $title = $this->selectSeoData(self::TITLE, $filter); + $title = $this->selectSeoData(self::TITLE, $filter,$priority); - if(!empty($filter) && $title == $this->{Seo::TITLE} || !empty($filter) && empty($this->{Seo::TITLE})) { + if(!empty($filter) && $priority==3 || !empty($filter) && empty($this->{Seo::TITLE})) { $array = $this->arrayBuilder($filter); @@ -143,13 +143,12 @@ class Seo extends Widget } else { return $this->prepareString($this->project_name); } - break; case self::DESCRIPTION: $filter = \Yii::$app->request->get('filters', []); - $description = $this->selectSeoData(self::DESCRIPTION, $filter); + $description = $this->selectSeoData(self::DESCRIPTION, $filter,$priority); if (!empty($description)) { @@ -178,7 +177,7 @@ class Seo extends Widget $sort = \Yii::$app->request->get('sort', []); $paginate = \Yii::$app->request->get('page', []); - $meta = $this->selectSeoData(self::META, $filter); + $meta = $this->selectSeoData(self::META, $filter,$priority); if(!empty($filter) && !$this->checkFilter($filter) && count($filter, COUNT_RECURSIVE) == 2){ $key = array_keys ( $filter); @@ -282,6 +281,9 @@ class Seo extends Widget protected function findSeoByDynamic() { +// print_r(\Yii::$app->controller->id); +// print_r(\Yii::$app->controller->action->id); +// die(); if(!empty($this->key)){ $query = SeoDynamic::find()->joinWith('seoCategory')->where(['controller' => \Yii::$app->controller->id, 'action' => \Yii::$app->controller->action->id, 'key' => $this->key]); @@ -318,11 +320,11 @@ class Seo extends Widget /** * @param $param * @param $filter + * @param $priority * @return mixed */ - protected function selectSeoData($param, $filter) + protected function selectSeoData($param, $filter, &$priority) { - $result = ''; $widgetData = static::findSeoByUrl($this->url); @@ -330,12 +332,15 @@ class Seo extends Widget $widgetDynamicData = $this->findSeoByDynamic(); if ($widgetData instanceof \artweb\artbox\seo\models\Seo) { + $priority = 1; $result = $widgetData->$param; }else if(!empty($this->$param) && empty($filter)) { + $priority = 2; $result = $this->$param; } else if ($widgetDynamicData instanceof SeoDynamic) { + $priority = 3; $result = $widgetDynamicData->lang->$param; } -- libgit2 0.21.4