diff --git a/backend/controllers/SeoCategoryController.php b/backend/controllers/SeoCategoryController.php
index 805891a..ea9046c 100755
--- a/backend/controllers/SeoCategoryController.php
+++ b/backend/controllers/SeoCategoryController.php
@@ -34,9 +34,7 @@ class SeoCategoryController extends Controller
],
'verbs' => [
'class' => VerbFilter::className(),
- 'actions' => [
- 'delete' => ['POST'],
- ],
+
],
];
}
diff --git a/backend/controllers/SeoController.php b/backend/controllers/SeoController.php
index d92a4ac..e3acfaf 100755
--- a/backend/controllers/SeoController.php
+++ b/backend/controllers/SeoController.php
@@ -34,9 +34,7 @@ class SeoController extends Controller
],
'verbs' => [
'class' => VerbFilter::className(),
- 'actions' => [
- 'delete' => ['POST'],
- ],
+
],
];
}
diff --git a/backend/controllers/SeoDynamicController.php b/backend/controllers/SeoDynamicController.php
index d0e5045..54c4162 100755
--- a/backend/controllers/SeoDynamicController.php
+++ b/backend/controllers/SeoDynamicController.php
@@ -34,9 +34,7 @@ class SeoDynamicController extends Controller
],
'verbs' => [
'class' => VerbFilter::className(),
- 'actions' => [
- 'delete' => ['POST'],
- ],
+
],
];
}
diff --git a/backend/views/seo-dynamic/_form.php b/backend/views/seo-dynamic/_form.php
index 9f8d22e..18c366d 100755
--- a/backend/views/seo-dynamic/_form.php
+++ b/backend/views/seo-dynamic/_form.php
@@ -7,7 +7,11 @@ use yii\widgets\ActiveForm;
/* @var $model common\models\SeoDynamic */
/* @var $form yii\widgets\ActiveForm */
?>
-
+
@@ -18,12 +22,27 @@ use yii\widgets\ActiveForm;
= $form->field($model, 'param')->textInput(['maxlength' => true]) ?>
+ //= $form->field($model, 'param')->dropDownList([
+// 'filter' => 'filter'
+// ],[ 'prompt' => 'Выберите параметр...']); ?>
+
+//=
+// $form->field($model, 'filter_mod')
+// ->radioList(
+// ['onefilter' => 'One filter', 'twofilters' => 'Two filters', 'brand_assigment' => 'Brand and assignment ']
+// )
+// ->label(false);
+// ?>
+
+
= $form->field($model, 'key')->textInput(['maxlength' => true]) ?>
= $form->field($model, 'fields')->textInput(['maxlength' => true]) ?>
= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
+ = $form->field($model, 'meta')->textInput(['maxlength' => true]) ?>
+
= $form->field($model, 'h1')->textInput(['maxlength' => true]) ?>
= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>
@@ -37,5 +56,17 @@ use yii\widgets\ActiveForm;
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/backend/views/seo-dynamic/index.php b/backend/views/seo-dynamic/index.php
index 991d5eb..20b9167 100755
--- a/backend/views/seo-dynamic/index.php
+++ b/backend/views/seo-dynamic/index.php
@@ -30,6 +30,7 @@ $this->params['breadcrumbs'][] = $this->title;
'name',
'action',
'fields',
+ 'meta',
// 'title',
// 'h1',
// 'description',
diff --git a/backend/views/seo-dynamic/view.php b/backend/views/seo-dynamic/view.php
index 631b795..36429f0 100755
--- a/backend/views/seo-dynamic/view.php
+++ b/backend/views/seo-dynamic/view.php
@@ -34,6 +34,7 @@ $this->params['breadcrumbs'][] = $this->title;
'action',
'fields',
'title',
+ 'meta',
'h1',
'description',
'seo_text:ntext',
diff --git a/common/models/SeoDynamic.php b/common/models/SeoDynamic.php
index 7ec02cd..2d58dad 100755
--- a/common/models/SeoDynamic.php
+++ b/common/models/SeoDynamic.php
@@ -41,7 +41,7 @@ class SeoDynamic extends \yii\db\ActiveRecord
[['seo_category_id', 'status'], 'integer'],
[['seo_text'], 'string'],
[['name', 'action'], 'string', 'max' => 200],
- [['fields', 'title', 'h1', 'description', 'param', 'key'], 'string', 'max' => 255],
+ [['fields', 'title', 'meta', 'h1', 'description', 'param', 'key'], 'string', 'max' => 255],
[['seo_category_id'], 'exist', 'skipOnError' => true, 'targetClass' => SeoCategory::className(), 'targetAttribute' => ['seo_category_id' => 'seo_category_id']],
];
}
@@ -58,6 +58,7 @@ class SeoDynamic extends \yii\db\ActiveRecord
'action' => Yii::t('app', 'action'),
'fields' => Yii::t('app', 'fields'),
'title' => Yii::t('app', 'title'),
+ 'meta' => Yii::t('app', 'meta'),
'h1' => Yii::t('app', 'h1'),
'description' => Yii::t('app', 'description'),
'seo_text' => Yii::t('app', 'seo_text'),
diff --git a/common/models/SeoDynamicSearch.php b/common/models/SeoDynamicSearch.php
index ce0d978..6c57b34 100755
--- a/common/models/SeoDynamicSearch.php
+++ b/common/models/SeoDynamicSearch.php
@@ -19,7 +19,7 @@ class SeoDynamicSearch extends SeoDynamic
{
return [
[['seo_dynamic_id', 'seo_category_id', 'status'], 'integer'],
- [['name', 'action', 'fields', 'title', 'h1', 'description', 'seo_text'], 'safe'],
+ [['name', 'action', 'fields', 'title', 'meta', 'h1', 'description', 'seo_text'], 'safe'],
];
}
@@ -68,6 +68,7 @@ class SeoDynamicSearch extends SeoDynamic
->andFilterWhere(['like', 'action', $this->action])
->andFilterWhere(['like', 'fields', $this->fields])
->andFilterWhere(['like', 'title', $this->title])
+ ->andFilterWhere(['like', 'meta', $this->title])
->andFilterWhere(['like', 'h1', $this->h1])
->andFilterWhere(['like', 'description', $this->description])
->andFilterWhere(['like', 'seo_text', $this->seo_text]);
diff --git a/frontend/config/main.php b/frontend/config/main.php
index 372b825..fedf9fd 100755
--- a/frontend/config/main.php
+++ b/frontend/config/main.php
@@ -87,7 +87,7 @@ return [
// 'products/' => 'products/index',
// 'products//-' => 'products/show',
'news/-' => 'news/show',
- 'brends/' => 'brends/show',
+ //'brends/' => 'brends/show',
'brends' => 'brends/index',
'blog' => 'articles/index',
'blog/-' => 'articles/show',
diff --git a/frontend/views/brends/show.php b/frontend/views/brends/show.php
index 9262623..d3ce6d5 100755
--- a/frontend/views/brends/show.php
+++ b/frontend/views/brends/show.php
@@ -5,7 +5,8 @@
use yii\widgets\LinkPager;
use yii\web\View;
- $this->title = $brend->name;
+// $this->title = $brend->name;
+ $this->params['seo']['fields']['name'] = $brend->name;
$this->registerMetaTag (['name' => 'description', 'content' => $brend->name]);
$this->registerMetaTag (['name' => 'keywords', 'content' => $brend->name]);
$this->params['breadcrumbs'][] = ['label' => 'Бренды', 'url' => ['/brends/index']];
@@ -30,11 +31,11 @@
-
+
-
= $this->render ('/products/_product', ['item' => $item, 'num' => 3]) ?>
-
+
diff --git a/frontend/views/catalog/brand.php b/frontend/views/catalog/brand.php
index aa4f578..31a1c8d 100644
--- a/frontend/views/catalog/brand.php
+++ b/frontend/views/catalog/brand.php
@@ -13,11 +13,7 @@ $this->title = $brand->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('products', 'Brands'), 'url' => ['catalog/brands']];
$this->params['breadcrumbs'][] = $brand->name;
-$this->params['seo']['seo_text'] = 'TEST SEO TEXT';
-$this->params['seo']['h1'] = 'TEST H1';
-$this->params['seo']['description'] = 'TEST DESCRIPTION';
-$this->params['seo']['fields']['name'] = 'TEST NAME FROM FIELD';
-$this->params['seo']['key']= 'product_list';
+$this->params['seo']['fields']['name'] = $brand->name;
$this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.css'));
$this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.skinHTML5.css'));
diff --git a/frontend/views/catalog/product.php b/frontend/views/catalog/product.php
index a568bab..683b2c2 100755
--- a/frontend/views/catalog/product.php
+++ b/frontend/views/catalog/product.php
@@ -2,10 +2,14 @@
use yii\widgets\Breadcrumbs;
use yii\web\View;
use yii\helpers\Url;
+use frontend\widgets\Seo;
-//$this->params['seo']['title'] = $product->fullname;
-$this->params['seo']['title'] = "Купить " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " в Киеве, Харькове, Украине: цены, отзывы - Rukzachok.com.ua";
-$this->params['seo']['description'] = "Заказать " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " - самые модные и стильные рюкзаки в Украине по лучшим ценам. Интернет магазин рюкзаков Rukzachok.com.ua";
+$this->params['seo']['key'] = $product->category->categoryName->value;
+$this->params['seo']['fields']['name'] = $product->fullname;
+$this->params['seo']['h1'] = !empty(Seo::widget([ 'row'=>'h1'])) ? Seo::widget([ 'row'=>'h1']) : $product->fullname;
+
+//$this->params['seo']['title'] = "Купить " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " в Киеве, Харькове, Украине: цены, отзывы - Rukzachok.com.ua";
+//$this->params['seo']['description'] = "Заказать " . substr($product->category->categoryName->value, 0, -2) . " " . $product->fullname . " - самые модные и стильные рюкзаки в Украине по лучшим ценам. Интернет магазин рюкзаков Rukzachok.com.ua";
$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)]);
@@ -96,7 +100,7 @@ $this->registerJs ("
-
= $product->fullname ?>
+
= Seo::widget([ 'row'=>'h1'])?>
enabledVariantsGrouped as $variantGroup) :?>
= $variantGroup->name2?>
diff --git a/frontend/views/catalog/products.php b/frontend/views/catalog/products.php
index 0e67291..facd06d 100755
--- a/frontend/views/catalog/products.php
+++ b/frontend/views/catalog/products.php
@@ -9,12 +9,12 @@ use yii\web\View;
use common\modules\product\helpers\ProductHelper;
use frontend\widgets\Seo;
//$this->title = $category->categoryName->value;
-$this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : "Купить " . substr($category->name, 0, -2) . " в Украине недорого |" . $category->name . " доставка в Киев, Харьков, Днепропетровск, Одесса - Rukzachok.com.ua";
+//$this->params['seo']['title'] = !empty($category->meta_title) ? $category->meta_title : "Купить " . substr($category->name, 0, -2) . " в Украине недорого |" . $category->name . " доставка в Киев, Харьков, Днепропетровск, Одесса - Rukzachok.com.ua";
$this->params['seo']['h1'] = !empty($category->h1) ? $category->h1 : $category->name;
$this->params['seo']['seo_text'] = $category->seo_text;
$this->params['seo']['description'] = $category->meta_desc;
$this->params['seo']['meta'] = $category->meta_robots;
-
+$this->params['seo']['category_name'] = $category->name;
//foreach($category->getParents()->all() as $parent) {
// $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]];
//}
diff --git a/frontend/widgets/Seo.php b/frontend/widgets/Seo.php
index 771b917..4ded1d1 100755
--- a/frontend/widgets/Seo.php
+++ b/frontend/widgets/Seo.php
@@ -2,6 +2,9 @@
namespace frontend\widgets;
use common\models\SeoDynamic;
+
+use common\modules\product\models\Brand;
+use common\modules\rubrication\models\TaxOption;
use yii\base\Widget;
use yii\helpers\Html;
@@ -11,12 +14,14 @@ class Seo extends Widget
public $row;
public $own_attr;
public $fields;
+ public $category_name;
public $description;
public $title;
public $meta;
public $seo_text;
public $h1;
public $key;
+ public $name;
public $project_name;
@@ -75,12 +80,49 @@ class Seo extends Widget
// if(!empty($filter_row)){
// return $filter_row;
// }
+
if (!empty($title)) {
return $title;
- } else {
- return $this->project_name;
}
+ $array = [
+ 'category' => $this->category_name
+ ];
+
+
+ if (isset($filter['brands']) && count($filter['brands']) == 1 )
+ {
+ $model = Brand::find()->where(['alias' => $filter['brands'][0]])->one();
+
+ $array['brand'] = $model->name;
+ }
+
+ if ( isset($filter['options']["pol"]) && count($filter['options']["pol"]) == 1)
+ {
+
+ $model = TaxOption::find()->where(['alias' => $filter['options']["pol"]])->one();
+ $array['sex'] = $model->value->value;
+
+
+ }
+
+ if (isset($filter['options']["naznacenie"]) && count($filter['options']["naznacenie"]) == 1){
+
+ $model = TaxOption::find()->where(['alias' => $filter['options']["naznacenie"]])->one();
+ $array['naz'] = $model->value->value;
+
+ }
+
+ if (isset($filter['options']["god"]) && count($filter['options']["god"]) == 1){
+ $model = TaxOption::find()->where(['alias' => $filter['options']["god"]])->one();
+ $array['year'] = $model->value->value;
+
+ }
+ return $this->getTitleString($array);
+// else {
+// return $this->project_name;
+// }
+
break;
case self::DESCRIPTION:
$description = $this->selectSeoData(self::DESCRIPTION);
@@ -163,10 +205,15 @@ class Seo extends Widget
protected function findSeoByDynamic()
{
- $query = SeoDynamic::find()->joinWith('seoCategory')->where(['controller' => \Yii::$app->controller->id, 'action' => \Yii::$app->controller->action->id]);
- if (!empty($this->key)) {
- $query->andWhere(['key' => $this->key]);
+
+ if(!empty($this->key)){
+
+ $query = SeoDynamic::find()->joinWith('seoCategory')->where(['controller' => \Yii::$app->controller->id, 'action' => \Yii::$app->controller->action->id, 'key' => $this->key]);
+ } else {
+
+ $query = SeoDynamic::find()->joinWith('seoCategory')->where(['controller' => \Yii::$app->controller->id, 'action' => \Yii::$app->controller->action->id]);
}
+
return $query->one();
}
@@ -210,5 +257,15 @@ class Seo extends Widget
}
+ public function getTitleString($array){
+ $template = "{category} {naz} {brand} {sex} {year} купить в Украине, Киев, Харькове - цены, фото, отзывы | Rukzachok.com.ua";
+ foreach ($array as $field_name => $field_value) {
+ $template = str_replace('{' . $field_name . '}', $field_value, $template);
+ }
+ $template = preg_replace('/\{.[^\}]*\}\s/','',$template);
+ return $template;
+
+ }
+
}
\ No newline at end of file
--
libgit2 0.21.4