Commit d29a2cfa16d73e1ed852ca05dadf0f3e1ee85e2e

Authored by Yarik
1 parent cb4152e7

Seo fix

frontend/views/catalog/products.php
... ... @@ -39,13 +39,6 @@ $this->registerJsFile(Yii::getAlias('@web/js/ion.rangeSlider.js'),[
39 39 'position' => View::POS_END,
40 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 44 <script type="text/javascript">
... ... @@ -191,7 +184,7 @@ function my_mb_ucfirst($str) {
191 184 </div>
192 185  
193 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 188 <div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer" style="display: none;">
196 189 <span itemprop="priceCurrency">UAH</span>
197 190 <span itemprop="lowPrice"><?= $priceLimits['min'] ?></span>
... ...
frontend/widgets/Seo.php
... ... @@ -2,15 +2,11 @@
2 2 namespace frontend\widgets;
3 3  
4 4 use common\models\SeoDynamic;
5   -use Yii;
6 5 use common\modules\product\models\Brand;
7 6 use common\modules\rubrication\models\TaxGroup;
8 7 use common\modules\rubrication\models\TaxOption;
9 8 use yii\base\Widget;
10 9 use yii\helpers\ArrayHelper;
11   -use yii\helpers\Html;
12   -use yii\helpers\Url;
13   -use yii\web\HttpException;
14 10  
15 11 class Seo extends Widget
16 12 {
... ... @@ -202,7 +198,7 @@ class Seo extends Widget
202 198 $title_string = $this->getTitleString($array);
203 199  
204 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 234 $paginate = \Yii::$app->request->get('page', []);
239 235  
240 236  
241   -
242 237 if (!empty($meta)) {
243   -
  238 +
244 239 $this->getView()->registerMetaTag([
245 240 'name' => 'robots',
246 241 'content' => $meta
... ... @@ -267,15 +262,14 @@ class Seo extends Widget
267 262 isset($filter['brands']) && count($filter['brands']) > 1 || isset($filter) && $this->checkFilter($filter)
268 263  
269 264 ) {
270   -
271 265 $this->getView()->registerMetaTag([
272 266 'name' => 'robots',
273 267 'content' => 'noindex,nofollow'
274 268 ]);
275 269  
276 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 273 || !empty($sort) || !empty($paginate) || isset($filter['prices'])
280 274 ) {
281 275 $this->getView()->registerMetaTag([
... ... @@ -369,18 +363,18 @@ class Seo extends Widget
369 363 $result = '';
370 364  
371 365 $widgetData = static::findSeoByUrl($this->url);
372   -
  366 +
373 367 if ($widgetData instanceof \common\models\Seo) {
374 368  
375 369 $result = $widgetData->$param;
376 370  
377 371 } else if (!empty($this->$param)) {
378   -
379 372 $result = $this->$param;
  373 +
380 374 } else {
381 375  
382 376 $widgetData = $this->findSeoByDynamic();
383   -
  377 +
384 378 if ($widgetData instanceof SeoDynamic) {
385 379  
386 380 $result = $widgetData->$param;
... ... @@ -407,6 +401,11 @@ class Seo extends Widget
407 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 412 \ No newline at end of file
... ...