diff --git a/backend/views/seo/_form.php b/backend/views/seo/_form.php index 7e03a52..9853be6 100755 --- a/backend/views/seo/_form.php +++ b/backend/views/seo/_form.php @@ -17,6 +17,8 @@ use mihaildev\elfinder\ElFinder; field($model, 'title')->textInput(['maxlength' => true]) ?> + field($model, 'meta')->textInput(['maxlength' => true]) ?> + field($model, 'description')->textInput(['maxlength' => true]) ?> field($model, 'h1')->textInput(['maxlength' => true]) ?> diff --git a/backend/views/seo/_search.php b/backend/views/seo/_search.php index d3b1fa4..fe3f629 100755 --- a/backend/views/seo/_search.php +++ b/backend/views/seo/_search.php @@ -19,7 +19,9 @@ use yii\widgets\ActiveForm; field($model, 'url') ?> - field($model, 'title') ?> + field($model, 'meta') ?> + + field($model, 'title') ?> field($model, 'description') ?> diff --git a/backend/views/seo/index.php b/backend/views/seo/index.php index 2937565..846ea6d 100755 --- a/backend/views/seo/index.php +++ b/backend/views/seo/index.php @@ -26,6 +26,7 @@ $this->params['breadcrumbs'][] = $this->title; 'seo_id', 'url:url', + 'meta', 'title', 'description', 'h1', diff --git a/backend/views/seo/view.php b/backend/views/seo/view.php index b98bcb4..fa1330f 100755 --- a/backend/views/seo/view.php +++ b/backend/views/seo/view.php @@ -31,6 +31,7 @@ $this->params['breadcrumbs'][] = $this->title; 'seo_id', 'url:url', 'title', + 'meta', 'description', 'h1', 'seo_text:ntext', diff --git a/common/models/Seo.php b/common/models/Seo.php index 8fccb9a..86df70e 100755 --- a/common/models/Seo.php +++ b/common/models/Seo.php @@ -10,6 +10,7 @@ use Yii; * @property integer $seo_id * @property string $url * @property string $title + * @property string $meta * @property string $description * @property string $h1 * @property string $seo_text @@ -32,7 +33,7 @@ class Seo extends \yii\db\ActiveRecord return [ [['url'], 'required'], [['seo_text'], 'string'], - [['url', 'title', 'description', 'h1'], 'string', 'max' => 255], + [['url', 'title', 'meta', 'description', 'h1'], 'string', 'max' => 255], ]; } @@ -45,6 +46,7 @@ class Seo extends \yii\db\ActiveRecord 'seo_id' => Yii::t('app', 'seo_id'), 'url' => Yii::t('app', 'url'), 'title' => Yii::t('app', 'title'), + 'meta' => Yii::t('app', 'meta_title'), 'description' => Yii::t('app', 'description'), 'h1' => Yii::t('app', 'h1'), 'seo_text' => Yii::t('app', 'seo_text'), diff --git a/common/models/SeoSearch.php b/common/models/SeoSearch.php index 14af48f..e8882bc 100755 --- a/common/models/SeoSearch.php +++ b/common/models/SeoSearch.php @@ -19,7 +19,7 @@ class SeoSearch extends Seo { return [ [['seo_id'], 'integer'], - [['url', 'title', 'description', 'h1', 'seo_text'], 'safe'], + [['url', 'title', 'meta', 'description', 'h1', 'seo_text'], 'safe'], ]; } @@ -64,6 +64,7 @@ class SeoSearch extends Seo $query->andFilterWhere(['like', 'url', $this->url]) ->andFilterWhere(['like', 'title', $this->title]) + ->andFilterWhere(['like', 'meta', $this->meta]) ->andFilterWhere(['like', 'description', $this->description]) ->andFilterWhere(['like', 'h1', $this->h1]) ->andFilterWhere(['like', 'seo_text', $this->seo_text]); diff --git a/frontend/views/catalog/product.php b/frontend/views/catalog/product.php index 0883aa3..a9cb310 100755 --- a/frontend/views/catalog/product.php +++ b/frontend/views/catalog/product.php @@ -2,7 +2,7 @@ use yii\widgets\Breadcrumbs; use yii\web\View; use yii\helpers\Url; -$this->params['seo']['title'] = $product->fullname ; +$this->params['seo']['title'] = $product->fullname; $this->title = $product->fullname; //$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname; //$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]); diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 9790b46..9b858c0 100755 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -85,6 +85,7 @@ ga('send', 'pageview'); <?= Seo::widget([ 'row'=>'title'])?> 'description'])?> + 'meta'])?> head () ?> diff --git a/frontend/widgets/Seo.php b/frontend/widgets/Seo.php index 72c1e16..ca50ade 100755 --- a/frontend/widgets/Seo.php +++ b/frontend/widgets/Seo.php @@ -12,6 +12,7 @@ class Seo extends Widget public $fields; public $description; public $title; + public $meta; public $seo_text; public $h1; public $key; @@ -22,6 +23,7 @@ class Seo extends Widget const SEO_TEXT = 'seo_text'; const DESCRIPTION = 'description'; + const META = 'meta'; const H1 = 'h1'; const TITLE = 'title'; @@ -52,27 +54,28 @@ class Seo extends Widget break; case self::TITLE: - $filter = \Yii::$app->request->get('filter', []); - if(!empty($filter)){ - $filter_row = ''; - foreach($filter as $sub_filter_name => $sub_filter_array){ - if($sub_filter_name=='options'){ - foreach($sub_filter_array as $f_name=>$f_values){ - $filter_row .= $f_name.':'.implode(',',$f_values).'|'; - } - } - - } - $this->fields['name'] = $filter_row; - } + $filter = \Yii::$app->request->get('filter', []); + // var_dump($filter );die(); +// if(!empty($filter)){ +// $filter_row = ''; +// foreach($filter as $sub_filter_name => $sub_filter_array){ +// if($sub_filter_name=='options'){ +// foreach($sub_filter_array as $f_name=>$f_values){ +// $filter_row .= $f_name.':'.implode(',',$f_values).'|'; +// } +// } +// +// } +// $this->fields['name'] = $filter_row; +// } $title = $this->selectSeoData(self::TITLE); - if(!empty($filter_row)){ - return $filter_row; - } - if(!empty($title)){ +// if(!empty($filter_row)){ +// return $filter_row; +// } + if (!empty($title)) { return $title; } else { return $this->project_name; @@ -82,16 +85,54 @@ class Seo extends Widget case self::DESCRIPTION: $description = $this->selectSeoData(self::DESCRIPTION); - if(!empty($description)){ + if (!empty($description)) { $this->getView()->registerMetaTag([ 'name' => 'description', - 'content' => $description + 'content' => $description ]); } break; + case self::META: + $meta = $this->selectSeoData(self::META); + + $filter = \Yii::$app->request->get('filter', []); + + + + if(!empty($meta)){ + + $this->getView()->registerMetaTag([ + 'name' => 'robots', + 'content' => $meta + ]); + + } else if ( + isset($filter['brands']) && count($filter['brands']) > 1 + || isset($filter['options']["pol"]) && count($filter['options']["pol"]) > 1 + || isset($filter['options']["naznacenie"]) && count($filter['options']["naznacenie"]) > 1 + || isset($filter['options']["god"]) && count($filter['options']["god"]) > 1 + || isset($filter['brands']) && count($filter['brands']) <= 1 && isset($filter['options']) && count($filter['options'], COUNT_RECURSIVE) >= 4 + || isset($filter['options']) && count($filter['options'], COUNT_RECURSIVE) > 4 + + ){ + $this->getView()->registerMetaTag([ + 'name' => 'robots', + 'content' => 'noindex,follow' + ]); + + } else if($filter) { + + $this->getView()->registerMetaTag([ + 'name' => 'robots', + 'content' => 'index,follow' + ]); + } + + + break; } @@ -145,7 +186,6 @@ class Seo extends Widget }else if(!empty($this->$param)){ $result = $this->$param; - } else { $widgetData = $this->findSeoByDynamic(); -- libgit2 0.21.4