Commit 1f3add0ac359899d0f5f53c76112a256c76c7d1e
1 parent
f92291b8
All seo
Showing
14 changed files
with
120 additions
and
33 deletions
Show diff stats
backend/controllers/SeoCategoryController.php
@@ -34,9 +34,7 @@ class SeoCategoryController extends Controller | @@ -34,9 +34,7 @@ class SeoCategoryController extends Controller | ||
34 | ], | 34 | ], |
35 | 'verbs' => [ | 35 | 'verbs' => [ |
36 | 'class' => VerbFilter::className(), | 36 | 'class' => VerbFilter::className(), |
37 | - 'actions' => [ | ||
38 | - 'delete' => ['POST'], | ||
39 | - ], | 37 | + |
40 | ], | 38 | ], |
41 | ]; | 39 | ]; |
42 | } | 40 | } |
backend/controllers/SeoController.php
@@ -34,9 +34,7 @@ class SeoController extends Controller | @@ -34,9 +34,7 @@ class SeoController extends Controller | ||
34 | ], | 34 | ], |
35 | 'verbs' => [ | 35 | 'verbs' => [ |
36 | 'class' => VerbFilter::className(), | 36 | 'class' => VerbFilter::className(), |
37 | - 'actions' => [ | ||
38 | - 'delete' => ['POST'], | ||
39 | - ], | 37 | + |
40 | ], | 38 | ], |
41 | ]; | 39 | ]; |
42 | } | 40 | } |
backend/controllers/SeoDynamicController.php
@@ -34,9 +34,7 @@ class SeoDynamicController extends Controller | @@ -34,9 +34,7 @@ class SeoDynamicController extends Controller | ||
34 | ], | 34 | ], |
35 | 'verbs' => [ | 35 | 'verbs' => [ |
36 | 'class' => VerbFilter::className(), | 36 | 'class' => VerbFilter::className(), |
37 | - 'actions' => [ | ||
38 | - 'delete' => ['POST'], | ||
39 | - ], | 37 | + |
40 | ], | 38 | ], |
41 | ]; | 39 | ]; |
42 | } | 40 | } |
backend/views/seo-dynamic/_form.php
@@ -7,7 +7,11 @@ use yii\widgets\ActiveForm; | @@ -7,7 +7,11 @@ use yii\widgets\ActiveForm; | ||
7 | /* @var $model common\models\SeoDynamic */ | 7 | /* @var $model common\models\SeoDynamic */ |
8 | /* @var $form yii\widgets\ActiveForm */ | 8 | /* @var $form yii\widgets\ActiveForm */ |
9 | ?> | 9 | ?> |
10 | - | 10 | +<style> |
11 | + #seodynamic-filter_mod { | ||
12 | + display: none; | ||
13 | + } | ||
14 | +</style> | ||
11 | <div class="seo-dynamic-form"> | 15 | <div class="seo-dynamic-form"> |
12 | 16 | ||
13 | <?php $form = ActiveForm::begin(); ?> | 17 | <?php $form = ActiveForm::begin(); ?> |
@@ -18,12 +22,27 @@ use yii\widgets\ActiveForm; | @@ -18,12 +22,27 @@ use yii\widgets\ActiveForm; | ||
18 | 22 | ||
19 | <?= $form->field($model, 'param')->textInput(['maxlength' => true]) ?> | 23 | <?= $form->field($model, 'param')->textInput(['maxlength' => true]) ?> |
20 | 24 | ||
25 | + <!-- --><?//= $form->field($model, 'param')->dropDownList([ | ||
26 | +// 'filter' => 'filter' | ||
27 | +// ],[ 'prompt' => 'Выберите параметр...']); ?> | ||
28 | +<!-- <div>--> | ||
29 | +<!-- --><?//= | ||
30 | +// $form->field($model, 'filter_mod') | ||
31 | +// ->radioList( | ||
32 | +// ['onefilter' => 'One filter', 'twofilters' => 'Two filters', 'brand_assigment' => 'Brand and assignment '] | ||
33 | +// ) | ||
34 | +// ->label(false); | ||
35 | +// ?> | ||
36 | +<!-- </div>--> | ||
37 | + | ||
21 | <?= $form->field($model, 'key')->textInput(['maxlength' => true]) ?> | 38 | <?= $form->field($model, 'key')->textInput(['maxlength' => true]) ?> |
22 | 39 | ||
23 | <?= $form->field($model, 'fields')->textInput(['maxlength' => true]) ?> | 40 | <?= $form->field($model, 'fields')->textInput(['maxlength' => true]) ?> |
24 | 41 | ||
25 | <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> | 42 | <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?> |
26 | 43 | ||
44 | + <?= $form->field($model, 'meta')->textInput(['maxlength' => true]) ?> | ||
45 | + | ||
27 | <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?> | 46 | <?= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?> |
28 | 47 | ||
29 | <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?> | 48 | <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?> |
@@ -37,5 +56,17 @@ use yii\widgets\ActiveForm; | @@ -37,5 +56,17 @@ use yii\widgets\ActiveForm; | ||
37 | </div> | 56 | </div> |
38 | 57 | ||
39 | <?php ActiveForm::end(); ?> | 58 | <?php ActiveForm::end(); ?> |
40 | - | 59 | +<!--<script>--> |
60 | +<!-- $('#seodynamic-param').on('change',function(){--> | ||
61 | +<!----> | ||
62 | +<!-- if($(this).val() == 'filter') {--> | ||
63 | +<!-- $('#seodynamic-filter_mod').show();--> | ||
64 | +<!-- alert('ok');--> | ||
65 | +<!-- } else {--> | ||
66 | +<!----> | ||
67 | +<!-- $('#seodynamic-filter_mod').hide();--> | ||
68 | +<!-- }--> | ||
69 | +<!-- });--> | ||
70 | +<!----> | ||
71 | +<!--</script>--> | ||
41 | </div> | 72 | </div> |
backend/views/seo-dynamic/index.php
@@ -30,6 +30,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -30,6 +30,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
30 | 'name', | 30 | 'name', |
31 | 'action', | 31 | 'action', |
32 | 'fields', | 32 | 'fields', |
33 | + 'meta', | ||
33 | // 'title', | 34 | // 'title', |
34 | // 'h1', | 35 | // 'h1', |
35 | // 'description', | 36 | // 'description', |
backend/views/seo-dynamic/view.php
@@ -34,6 +34,7 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -34,6 +34,7 @@ $this->params['breadcrumbs'][] = $this->title; | ||
34 | 'action', | 34 | 'action', |
35 | 'fields', | 35 | 'fields', |
36 | 'title', | 36 | 'title', |
37 | + 'meta', | ||
37 | 'h1', | 38 | 'h1', |
38 | 'description', | 39 | 'description', |
39 | 'seo_text:ntext', | 40 | 'seo_text:ntext', |
common/models/SeoDynamic.php
@@ -41,7 +41,7 @@ class SeoDynamic extends \yii\db\ActiveRecord | @@ -41,7 +41,7 @@ class SeoDynamic extends \yii\db\ActiveRecord | ||
41 | [['seo_category_id', 'status'], 'integer'], | 41 | [['seo_category_id', 'status'], 'integer'], |
42 | [['seo_text'], 'string'], | 42 | [['seo_text'], 'string'], |
43 | [['name', 'action'], 'string', 'max' => 200], | 43 | [['name', 'action'], 'string', 'max' => 200], |
44 | - [['fields', 'title', 'h1', 'description', 'param', 'key'], 'string', 'max' => 255], | 44 | + [['fields', 'title', 'meta', 'h1', 'description', 'param', 'key'], 'string', 'max' => 255], |
45 | [['seo_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeoCategory::className(), 'targetAttribute' => ['seo_category_id' => 'seo_category_id']], | 45 | [['seo_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeoCategory::className(), 'targetAttribute' => ['seo_category_id' => 'seo_category_id']], |
46 | ]; | 46 | ]; |
47 | } | 47 | } |
@@ -58,6 +58,7 @@ class SeoDynamic extends \yii\db\ActiveRecord | @@ -58,6 +58,7 @@ class SeoDynamic extends \yii\db\ActiveRecord | ||
58 | 'action' => Yii::t('app', 'action'), | 58 | 'action' => Yii::t('app', 'action'), |
59 | 'fields' => Yii::t('app', 'fields'), | 59 | 'fields' => Yii::t('app', 'fields'), |
60 | 'title' => Yii::t('app', 'title'), | 60 | 'title' => Yii::t('app', 'title'), |
61 | + 'meta' => Yii::t('app', 'meta'), | ||
61 | 'h1' => Yii::t('app', 'h1'), | 62 | 'h1' => Yii::t('app', 'h1'), |
62 | 'description' => Yii::t('app', 'description'), | 63 | 'description' => Yii::t('app', 'description'), |
63 | 'seo_text' => Yii::t('app', 'seo_text'), | 64 | 'seo_text' => Yii::t('app', 'seo_text'), |
common/models/SeoDynamicSearch.php
@@ -19,7 +19,7 @@ class SeoDynamicSearch extends SeoDynamic | @@ -19,7 +19,7 @@ class SeoDynamicSearch extends SeoDynamic | ||
19 | { | 19 | { |
20 | return [ | 20 | return [ |
21 | [['seo_dynamic_id', 'seo_category_id', 'status'], 'integer'], | 21 | [['seo_dynamic_id', 'seo_category_id', 'status'], 'integer'], |
22 | - [['name', 'action', 'fields', 'title', 'h1', 'description', 'seo_text'], 'safe'], | 22 | + [['name', 'action', 'fields', 'title', 'meta', 'h1', 'description', 'seo_text'], 'safe'], |
23 | ]; | 23 | ]; |
24 | } | 24 | } |
25 | 25 | ||
@@ -68,6 +68,7 @@ class SeoDynamicSearch extends SeoDynamic | @@ -68,6 +68,7 @@ class SeoDynamicSearch extends SeoDynamic | ||
68 | ->andFilterWhere(['like', 'action', $this->action]) | 68 | ->andFilterWhere(['like', 'action', $this->action]) |
69 | ->andFilterWhere(['like', 'fields', $this->fields]) | 69 | ->andFilterWhere(['like', 'fields', $this->fields]) |
70 | ->andFilterWhere(['like', 'title', $this->title]) | 70 | ->andFilterWhere(['like', 'title', $this->title]) |
71 | + ->andFilterWhere(['like', 'meta', $this->title]) | ||
71 | ->andFilterWhere(['like', 'h1', $this->h1]) | 72 | ->andFilterWhere(['like', 'h1', $this->h1]) |
72 | ->andFilterWhere(['like', 'description', $this->description]) | 73 | ->andFilterWhere(['like', 'description', $this->description]) |
73 | ->andFilterWhere(['like', 'seo_text', $this->seo_text]); | 74 | ->andFilterWhere(['like', 'seo_text', $this->seo_text]); |
frontend/config/main.php
@@ -87,7 +87,7 @@ return [ | @@ -87,7 +87,7 @@ return [ | ||
87 | // 'products/<translit:\w+>' => 'products/index', | 87 | // 'products/<translit:\w+>' => 'products/index', |
88 | // 'products/<translit_rubric:\w+>/<translit:[\w\-]+>-<id:\d+>' => 'products/show', | 88 | // 'products/<translit_rubric:\w+>/<translit:[\w\-]+>-<id:\d+>' => 'products/show', |
89 | 'news/<translit:\w+>-<id:\d+>' => 'news/show', | 89 | 'news/<translit:\w+>-<id:\d+>' => 'news/show', |
90 | - 'brends/<translit:[\w\-]+>' => 'brends/show', | 90 | + //'brends/<translit:[\w\-]+>' => 'brends/show', |
91 | 'brends' => 'brends/index', | 91 | 'brends' => 'brends/index', |
92 | 'blog' => 'articles/index', | 92 | 'blog' => 'articles/index', |
93 | 'blog/<translit:[\w\-]+>-<id:\d+>' => 'articles/show', | 93 | 'blog/<translit:[\w\-]+>-<id:\d+>' => 'articles/show', |
frontend/views/brends/show.php
@@ -5,7 +5,8 @@ | @@ -5,7 +5,8 @@ | ||
5 | use yii\widgets\LinkPager; | 5 | use yii\widgets\LinkPager; |
6 | use yii\web\View; | 6 | use yii\web\View; |
7 | 7 | ||
8 | - $this->title = $brend->name; | 8 | +// $this->title = $brend->name; |
9 | + $this->params['seo']['fields']['name'] = $brend->name; | ||
9 | $this->registerMetaTag (['name' => 'description', 'content' => $brend->name]); | 10 | $this->registerMetaTag (['name' => 'description', 'content' => $brend->name]); |
10 | $this->registerMetaTag (['name' => 'keywords', 'content' => $brend->name]); | 11 | $this->registerMetaTag (['name' => 'keywords', 'content' => $brend->name]); |
11 | $this->params['breadcrumbs'][] = ['label' => 'Бренды', 'url' => ['/brends/index']]; | 12 | $this->params['breadcrumbs'][] = ['label' => 'Бренды', 'url' => ['/brends/index']]; |
@@ -30,11 +31,11 @@ | @@ -30,11 +31,11 @@ | ||
30 | 31 | ||
31 | <ul> | 32 | <ul> |
32 | 33 | ||
33 | - <?phpforeach ($products as $item): ?> | 34 | + <?php foreach ($products as $item): ?> |
34 | <li class="item"> | 35 | <li class="item"> |
35 | <?= $this->render ('/products/_product', ['item' => $item, 'num' => 3]) ?> | 36 | <?= $this->render ('/products/_product', ['item' => $item, 'num' => 3]) ?> |
36 | </li> | 37 | </li> |
37 | - <?phpendforeach; ?> | 38 | + <?php endforeach; ?> |
38 | 39 | ||
39 | </ul> | 40 | </ul> |
40 | <div class="both"></div> | 41 | <div class="both"></div> |
frontend/views/catalog/brand.php
@@ -13,11 +13,7 @@ $this->title = $brand->name; | @@ -13,11 +13,7 @@ $this->title = $brand->name; | ||
13 | $this->params['breadcrumbs'][] = ['label' => Yii::t('products', 'Brands'), 'url' => ['catalog/brands']]; | 13 | $this->params['breadcrumbs'][] = ['label' => Yii::t('products', 'Brands'), 'url' => ['catalog/brands']]; |
14 | $this->params['breadcrumbs'][] = $brand->name; | 14 | $this->params['breadcrumbs'][] = $brand->name; |
15 | 15 | ||
16 | -$this->params['seo']['seo_text'] = 'TEST SEO TEXT'; | ||
17 | -$this->params['seo']['h1'] = 'TEST H1'; | ||
18 | -$this->params['seo']['description'] = 'TEST DESCRIPTION'; | ||
19 | -$this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD'; | ||
20 | -$this->params['seo']['key']= 'product_list'; | 16 | +$this->params['seo']['fields']['name'] = $brand->name; |
21 | 17 | ||
22 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.css')); | 18 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.css')); |
23 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.skinHTML5.css')); | 19 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.skinHTML5.css')); |
frontend/views/catalog/product.php
@@ -2,10 +2,14 @@ | @@ -2,10 +2,14 @@ | ||
2 | use yii\widgets\Breadcrumbs; | 2 | use yii\widgets\Breadcrumbs; |
3 | use yii\web\View; | 3 | use yii\web\View; |
4 | use yii\helpers\Url; | 4 | use yii\helpers\Url; |
5 | +use frontend\widgets\Seo; | ||
5 | 6 | ||
6 | -//$this->params['seo']['title'] = $product->fullname; | ||
7 | -$this->params['seo']['title'] = "Купить " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " в Киеве, Харькове, Украине: цены, отзывы - Rukzachok.com.ua"; | ||
8 | -$this->params['seo']['description'] = "Заказать " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " - самые модные и стильные рюкзаки в Украине по лучшим ценам. Интернет магазин рюкзаков Rukzachok.com.ua"; | 7 | +$this->params['seo']['key'] = $product->category->categoryName->value; |
8 | +$this->params['seo']['fields']['name'] = $product->fullname; | ||
9 | +$this->params['seo']['h1'] = !empty(Seo::widget([ 'row'=>'h1'])) ? Seo::widget([ 'row'=>'h1']) : $product->fullname; | ||
10 | + | ||
11 | +//$this->params['seo']['title'] = "Купить " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " в Киеве, Харькове, Украине: цены, отзывы - Rukzachok.com.ua"; | ||
12 | +//$this->params['seo']['description'] = "Заказать " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " - самые модные и стильные рюкзаки в Украине по лучшим ценам. Интернет магазин рюкзаков Rukzachok.com.ua"; | ||
9 | $this->title = $product->fullname; | 13 | $this->title = $product->fullname; |
10 | //$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname; | 14 | //$this->title = (! empty($product->meta_title)) ? $product->meta_title : $product->fullname; |
11 | //$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]); | 15 | //$this->registerMetaTag (['name' => 'description', 'content' => ((! empty($product->meta_description)) ? $product->meta_description : $product->fullname)]); |
@@ -96,7 +100,7 @@ $this->registerJs (" | @@ -96,7 +100,7 @@ $this->registerJs (" | ||
96 | <?php endif; ?> | 100 | <?php endif; ?> |
97 | <div class="loyout"> | 101 | <div class="loyout"> |
98 | <div class="productLeftBar"> | 102 | <div class="productLeftBar"> |
99 | - <h1><?= $product->fullname ?></h1> | 103 | + <h1><?= Seo::widget([ 'row'=>'h1'])?></h1> |
100 | <?php foreach($product->enabledVariantsGrouped as $variantGroup) :?> | 104 | <?php foreach($product->enabledVariantsGrouped as $variantGroup) :?> |
101 | <div class="begin"><?= $variantGroup->name2?></div> | 105 | <div class="begin"><?= $variantGroup->name2?></div> |
102 | <ul class="product_mod"> | 106 | <ul class="product_mod"> |
frontend/views/catalog/products.php
@@ -9,12 +9,12 @@ use yii\web\View; | @@ -9,12 +9,12 @@ use yii\web\View; | ||
9 | use common\modules\product\helpers\ProductHelper; | 9 | use common\modules\product\helpers\ProductHelper; |
10 | use frontend\widgets\Seo; | 10 | use frontend\widgets\Seo; |
11 | //$this->title = $category->categoryName->value; | 11 | //$this->title = $category->categoryName->value; |
12 | -$this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : "Купить " . substr($category->name, 0, -2) . " в Украине недорого |" . $category->name . " доставка в Киев, Харьков, Днепропетровск, Одесса - Rukzachok.com.ua"; | 12 | +//$this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : "Купить " . substr($category->name, 0, -2) . " в Украине недорого |" . $category->name . " доставка в Киев, Харьков, Днепропетровск, Одесса - Rukzachok.com.ua"; |
13 | $this->params['seo']['h1'] = !empty($category->h1) ? $category->h1 : $category->name; | 13 | $this->params['seo']['h1'] = !empty($category->h1) ? $category->h1 : $category->name; |
14 | $this->params['seo']['seo_text'] = $category->seo_text; | 14 | $this->params['seo']['seo_text'] = $category->seo_text; |
15 | $this->params['seo']['description'] = $category->meta_desc; | 15 | $this->params['seo']['description'] = $category->meta_desc; |
16 | $this->params['seo']['meta'] = $category->meta_robots; | 16 | $this->params['seo']['meta'] = $category->meta_robots; |
17 | - | 17 | +$this->params['seo']['category_name'] = $category->name; |
18 | //foreach($category->getParents()->all() as $parent) { | 18 | //foreach($category->getParents()->all() as $parent) { |
19 | // $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; | 19 | // $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; |
20 | //} | 20 | //} |
frontend/widgets/Seo.php
@@ -2,6 +2,9 @@ | @@ -2,6 +2,9 @@ | ||
2 | namespace frontend\widgets; | 2 | namespace frontend\widgets; |
3 | 3 | ||
4 | use common\models\SeoDynamic; | 4 | use common\models\SeoDynamic; |
5 | + | ||
6 | +use common\modules\product\models\Brand; | ||
7 | +use common\modules\rubrication\models\TaxOption; | ||
5 | use yii\base\Widget; | 8 | use yii\base\Widget; |
6 | use yii\helpers\Html; | 9 | use yii\helpers\Html; |
7 | 10 | ||
@@ -11,12 +14,14 @@ class Seo extends Widget | @@ -11,12 +14,14 @@ class Seo extends Widget | ||
11 | public $row; | 14 | public $row; |
12 | public $own_attr; | 15 | public $own_attr; |
13 | public $fields; | 16 | public $fields; |
17 | + public $category_name; | ||
14 | public $description; | 18 | public $description; |
15 | public $title; | 19 | public $title; |
16 | public $meta; | 20 | public $meta; |
17 | public $seo_text; | 21 | public $seo_text; |
18 | public $h1; | 22 | public $h1; |
19 | public $key; | 23 | public $key; |
24 | + public $name; | ||
20 | public $project_name; | 25 | public $project_name; |
21 | 26 | ||
22 | 27 | ||
@@ -75,12 +80,49 @@ class Seo extends Widget | @@ -75,12 +80,49 @@ class Seo extends Widget | ||
75 | // if(!empty($filter_row)){ | 80 | // if(!empty($filter_row)){ |
76 | // return $filter_row; | 81 | // return $filter_row; |
77 | // } | 82 | // } |
83 | + | ||
78 | if (!empty($title)) { | 84 | if (!empty($title)) { |
79 | return $title; | 85 | return $title; |
80 | - } else { | ||
81 | - return $this->project_name; | ||
82 | } | 86 | } |
83 | 87 | ||
88 | + $array = [ | ||
89 | + 'category' => $this->category_name | ||
90 | + ]; | ||
91 | + | ||
92 | + | ||
93 | + if (isset($filter['brands']) && count($filter['brands']) == 1 ) | ||
94 | + { | ||
95 | + $model = Brand::find()->where(['alias' => $filter['brands'][0]])->one(); | ||
96 | + | ||
97 | + $array['brand'] = $model->name; | ||
98 | + } | ||
99 | + | ||
100 | + if ( isset($filter['options']["pol"]) && count($filter['options']["pol"]) == 1) | ||
101 | + { | ||
102 | + | ||
103 | + $model = TaxOption::find()->where(['alias' => $filter['options']["pol"]])->one(); | ||
104 | + $array['sex'] = $model->value->value; | ||
105 | + | ||
106 | + | ||
107 | + } | ||
108 | + | ||
109 | + if (isset($filter['options']["naznacenie"]) && count($filter['options']["naznacenie"]) == 1){ | ||
110 | + | ||
111 | + $model = TaxOption::find()->where(['alias' => $filter['options']["naznacenie"]])->one(); | ||
112 | + $array['naz'] = $model->value->value; | ||
113 | + | ||
114 | + } | ||
115 | + | ||
116 | + if (isset($filter['options']["god"]) && count($filter['options']["god"]) == 1){ | ||
117 | + $model = TaxOption::find()->where(['alias' => $filter['options']["god"]])->one(); | ||
118 | + $array['year'] = $model->value->value; | ||
119 | + | ||
120 | + } | ||
121 | + return $this->getTitleString($array); | ||
122 | +// else { | ||
123 | +// return $this->project_name; | ||
124 | +// } | ||
125 | + | ||
84 | break; | 126 | break; |
85 | case self::DESCRIPTION: | 127 | case self::DESCRIPTION: |
86 | $description = $this->selectSeoData(self::DESCRIPTION); | 128 | $description = $this->selectSeoData(self::DESCRIPTION); |
@@ -163,10 +205,15 @@ class Seo extends Widget | @@ -163,10 +205,15 @@ class Seo extends Widget | ||
163 | 205 | ||
164 | protected function findSeoByDynamic() | 206 | protected function findSeoByDynamic() |
165 | { | 207 | { |
166 | - $query = SeoDynamic::find()->joinWith('seoCategory')->where(['controller' => \Yii::$app->controller->id, 'action' => \Yii::$app->controller->action->id]); | ||
167 | - if (!empty($this->key)) { | ||
168 | - $query->andWhere(['key' => $this->key]); | 208 | + |
209 | + if(!empty($this->key)){ | ||
210 | + | ||
211 | + $query = SeoDynamic::find()->joinWith('seoCategory')->where(['controller' => \Yii::$app->controller->id, 'action' => \Yii::$app->controller->action->id, 'key' => $this->key]); | ||
212 | + } else { | ||
213 | + | ||
214 | + $query = SeoDynamic::find()->joinWith('seoCategory')->where(['controller' => \Yii::$app->controller->id, 'action' => \Yii::$app->controller->action->id]); | ||
169 | } | 215 | } |
216 | + | ||
170 | return $query->one(); | 217 | return $query->one(); |
171 | } | 218 | } |
172 | 219 | ||
@@ -210,5 +257,15 @@ class Seo extends Widget | @@ -210,5 +257,15 @@ class Seo extends Widget | ||
210 | 257 | ||
211 | } | 258 | } |
212 | 259 | ||
260 | + public function getTitleString($array){ | ||
261 | + $template = "{category} {naz} {brand} {sex} {year} купить в Украине, Киев, Харькове - цены, фото, отзывы | Rukzachok.com.ua"; | ||
262 | + foreach ($array as $field_name => $field_value) { | ||
263 | + $template = str_replace('{' . $field_name . '}', $field_value, $template); | ||
264 | + } | ||
265 | + $template = preg_replace('/\{.[^\}]*\}\s/','',$template); | ||
266 | + return $template; | ||
267 | + | ||
268 | + } | ||
269 | + | ||
213 | 270 | ||
214 | } | 271 | } |
215 | \ No newline at end of file | 272 | \ No newline at end of file |