Commit d29a2cfa16d73e1ed852ca05dadf0f3e1ee85e2e
1 parent
cb4152e7
Seo fix
Showing
2 changed files
with
14 additions
and
22 deletions
Show diff stats
frontend/views/catalog/products.php
| @@ -39,13 +39,6 @@ $this->registerJsFile(Yii::getAlias('@web/js/ion.rangeSlider.js'),[ | @@ -39,13 +39,6 @@ $this->registerJsFile(Yii::getAlias('@web/js/ion.rangeSlider.js'),[ | ||
| 39 | 'position' => View::POS_END, | 39 | 'position' => View::POS_END, |
| 40 | 'depends' => ['yii\web\JqueryAsset'] | 40 | 'depends' => ['yii\web\JqueryAsset'] |
| 41 | ]); | 41 | ]); |
| 42 | - | ||
| 43 | - | ||
| 44 | -function my_mb_ucfirst($str) { | ||
| 45 | - $str = strtolower($str); | ||
| 46 | - $fc = mb_strtoupper(mb_substr($str, 0, 1)); | ||
| 47 | - return $fc.mb_substr($str, 1); | ||
| 48 | -} | ||
| 49 | ?> | 42 | ?> |
| 50 | 43 | ||
| 51 | <script type="text/javascript"> | 44 | <script type="text/javascript"> |
| @@ -191,7 +184,7 @@ function my_mb_ucfirst($str) { | @@ -191,7 +184,7 @@ function my_mb_ucfirst($str) { | ||
| 191 | </div> | 184 | </div> |
| 192 | 185 | ||
| 193 | <div class="content" itemscope itemtype="http://schema.org/Product"> | 186 | <div class="content" itemscope itemtype="http://schema.org/Product"> |
| 194 | - <div itemprop="name"><h1><?= my_mb_ucfirst(Seo::widget([ 'row'=>'h1']))?></h1></div> | 187 | + <div itemprop="name"><h1><?= Seo::widget([ 'row'=>'h1'])?></h1></div> |
| 195 | <div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer" style="display: none;"> | 188 | <div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer" style="display: none;"> |
| 196 | <span itemprop="priceCurrency">UAH</span> | 189 | <span itemprop="priceCurrency">UAH</span> |
| 197 | <span itemprop="lowPrice"><?= $priceLimits['min'] ?></span> | 190 | <span itemprop="lowPrice"><?= $priceLimits['min'] ?></span> |
frontend/widgets/Seo.php
| @@ -2,15 +2,11 @@ | @@ -2,15 +2,11 @@ | ||
| 2 | namespace frontend\widgets; | 2 | namespace frontend\widgets; |
| 3 | 3 | ||
| 4 | use common\models\SeoDynamic; | 4 | use common\models\SeoDynamic; |
| 5 | -use Yii; | ||
| 6 | use common\modules\product\models\Brand; | 5 | use common\modules\product\models\Brand; |
| 7 | use common\modules\rubrication\models\TaxGroup; | 6 | use common\modules\rubrication\models\TaxGroup; |
| 8 | use common\modules\rubrication\models\TaxOption; | 7 | use common\modules\rubrication\models\TaxOption; |
| 9 | use yii\base\Widget; | 8 | use yii\base\Widget; |
| 10 | use yii\helpers\ArrayHelper; | 9 | use yii\helpers\ArrayHelper; |
| 11 | -use yii\helpers\Html; | ||
| 12 | -use yii\helpers\Url; | ||
| 13 | -use yii\web\HttpException; | ||
| 14 | 10 | ||
| 15 | class Seo extends Widget | 11 | class Seo extends Widget |
| 16 | { | 12 | { |
| @@ -202,7 +198,7 @@ class Seo extends Widget | @@ -202,7 +198,7 @@ class Seo extends Widget | ||
| 202 | $title_string = $this->getTitleString($array); | 198 | $title_string = $this->getTitleString($array); |
| 203 | 199 | ||
| 204 | if($title_string){ | 200 | if($title_string){ |
| 205 | - return $title_string; | 201 | + return $this->my_mb_ucfirst(trim($title_string)); |
| 206 | } | 202 | } |
| 207 | 203 | ||
| 208 | } | 204 | } |
| @@ -238,9 +234,8 @@ class Seo extends Widget | @@ -238,9 +234,8 @@ class Seo extends Widget | ||
| 238 | $paginate = \Yii::$app->request->get('page', []); | 234 | $paginate = \Yii::$app->request->get('page', []); |
| 239 | 235 | ||
| 240 | 236 | ||
| 241 | - | ||
| 242 | if (!empty($meta)) { | 237 | if (!empty($meta)) { |
| 243 | - | 238 | + |
| 244 | $this->getView()->registerMetaTag([ | 239 | $this->getView()->registerMetaTag([ |
| 245 | 'name' => 'robots', | 240 | 'name' => 'robots', |
| 246 | 'content' => $meta | 241 | 'content' => $meta |
| @@ -267,15 +262,14 @@ class Seo extends Widget | @@ -267,15 +262,14 @@ class Seo extends Widget | ||
| 267 | isset($filter['brands']) && count($filter['brands']) > 1 || isset($filter) && $this->checkFilter($filter) | 262 | isset($filter['brands']) && count($filter['brands']) > 1 || isset($filter) && $this->checkFilter($filter) |
| 268 | 263 | ||
| 269 | ) { | 264 | ) { |
| 270 | - | ||
| 271 | $this->getView()->registerMetaTag([ | 265 | $this->getView()->registerMetaTag([ |
| 272 | 'name' => 'robots', | 266 | 'name' => 'robots', |
| 273 | 'content' => 'noindex,nofollow' | 267 | 'content' => 'noindex,nofollow' |
| 274 | ]); | 268 | ]); |
| 275 | 269 | ||
| 276 | } else if ( | 270 | } else if ( |
| 277 | - isset($filter['brands']) && count($filter['brands']) <= 1 && isset($filter) && count($filter, COUNT_RECURSIVE) >= 4 | ||
| 278 | - || isset($filter) && count($filter, COUNT_RECURSIVE) >1 | 271 | + isset($filter['brands']) && count($filter['brands']) <= 1 && isset($filter) && count($filter, COUNT_RECURSIVE) >= 2 |
| 272 | + || isset($filter) && count($filter, COUNT_RECURSIVE) >= 2 | ||
| 279 | || !empty($sort) || !empty($paginate) || isset($filter['prices']) | 273 | || !empty($sort) || !empty($paginate) || isset($filter['prices']) |
| 280 | ) { | 274 | ) { |
| 281 | $this->getView()->registerMetaTag([ | 275 | $this->getView()->registerMetaTag([ |
| @@ -369,18 +363,18 @@ class Seo extends Widget | @@ -369,18 +363,18 @@ class Seo extends Widget | ||
| 369 | $result = ''; | 363 | $result = ''; |
| 370 | 364 | ||
| 371 | $widgetData = static::findSeoByUrl($this->url); | 365 | $widgetData = static::findSeoByUrl($this->url); |
| 372 | - | 366 | + |
| 373 | if ($widgetData instanceof \common\models\Seo) { | 367 | if ($widgetData instanceof \common\models\Seo) { |
| 374 | 368 | ||
| 375 | $result = $widgetData->$param; | 369 | $result = $widgetData->$param; |
| 376 | 370 | ||
| 377 | } else if (!empty($this->$param)) { | 371 | } else if (!empty($this->$param)) { |
| 378 | - | ||
| 379 | $result = $this->$param; | 372 | $result = $this->$param; |
| 373 | + | ||
| 380 | } else { | 374 | } else { |
| 381 | 375 | ||
| 382 | $widgetData = $this->findSeoByDynamic(); | 376 | $widgetData = $this->findSeoByDynamic(); |
| 383 | - | 377 | + |
| 384 | if ($widgetData instanceof SeoDynamic) { | 378 | if ($widgetData instanceof SeoDynamic) { |
| 385 | 379 | ||
| 386 | $result = $widgetData->$param; | 380 | $result = $widgetData->$param; |
| @@ -407,6 +401,11 @@ class Seo extends Widget | @@ -407,6 +401,11 @@ class Seo extends Widget | ||
| 407 | return false; | 401 | return false; |
| 408 | 402 | ||
| 409 | } | 403 | } |
| 410 | - | 404 | + |
| 405 | + public function my_mb_ucfirst($str) { | ||
| 406 | + $str = strtolower($str); | ||
| 407 | + $fc = mb_strtoupper(mb_substr($str, 0, 1)); | ||
| 408 | + return $fc.mb_substr($str, 1); | ||
| 409 | + } | ||
| 411 | 410 | ||
| 412 | } | 411 | } |
| 413 | \ No newline at end of file | 412 | \ No newline at end of file |