Commit f3eb325dd0d6cfc1ef361d854f60dd7981b65dc0
1 parent
74873101
Breadcrumbs fix
Showing
2 changed files
with
29 additions
and
11 deletions
Show diff stats
frontend/views/catalog/products.php
@@ -29,8 +29,8 @@ | @@ -29,8 +29,8 @@ | ||
29 | //foreach($category->getParents()->all() as $parent) { | 29 | //foreach($category->getParents()->all() as $parent) { |
30 | // $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; | 30 | // $this->params['breadcrumbs'][] = ['label' => $parent->categoryName->value, 'url' => ['catalog/category', 'category' => $parent]]; |
31 | //} | 31 | //} |
32 | - $this->params['breadcrumbs'][] = ['label' => '<span itemprop="title">Каталог</span>', 'url' => Url::to(['catalog/category']),'itemprop' => 'url' ]; | ||
33 | - $this->params['breadcrumbs'][] = Html::tag('span', $category->categoryName->value, ['itemprop' => 'title']); | 32 | + $this->params['breadcrumbs'][] = ['label' => '<span itemprop="name">Каталог</span>', 'url' => Url::to(['catalog/category']),'itemprop' => 'url' ]; |
33 | + $this->params['breadcrumbs'][] = Html::tag('span', $category->categoryName->value, ['itemprop' => 'name']); | ||
34 | 34 | ||
35 | 35 | ||
36 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.css')); | 36 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.css')); |
frontend/views/layouts/main.php
@@ -241,22 +241,40 @@ $this->registerJs(" | @@ -241,22 +241,40 @@ $this->registerJs(" | ||
241 | <?= $this->render('main-menu')?> | 241 | <?= $this->render('main-menu')?> |
242 | <div class="both"></div> | 242 | <div class="both"></div> |
243 | </div> | 243 | </div> |
244 | - | ||
245 | <div class="wrapper_all"> | 244 | <div class="wrapper_all"> |
246 | <?php if(isset ($this->params['breadcrumbs'])):?> | 245 | <?php if(isset ($this->params['breadcrumbs'])):?> |
247 | - <span itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> | ||
248 | <nav class="bread-crumbs"> | 246 | <nav class="bread-crumbs"> |
249 | - <?= Breadcrumbs::widget ([ | ||
250 | - 'homeLink' => ['label' => '<span itemprop="title">Главная</span>', 'url' => Url::to(['/']),'itemprop' => 'url', ], | ||
251 | - 'itemTemplate' => "<li>{link}</li>\n", // template for all links | ||
252 | - 'links' => $this->params['breadcrumbs'], | 247 | + <?php |
248 | + $links = $this->params['breadcrumbs']; | ||
249 | + foreach($links as $index => $link) { | ||
250 | + if(is_array($link)) { | ||
251 | + $links[$index]['template'] = "<li itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>{link}<meta itemprop='position' content='".($index + 2)."' /></li>"; | ||
252 | + $links[$index]['itemprop'] = 'item'; | ||
253 | + } else { | ||
254 | + $links[$index] = [ | ||
255 | + 'label' => $link, | ||
256 | + 'template' => "<li itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>{link}<meta itemprop='position' content='".($index + 2)."' /><meta itemprop='item' content='".Url::to('', true)."'></li>", | ||
257 | + 'itemprop' => 'item', | ||
258 | + ]; | ||
259 | + } | ||
260 | + } | ||
261 | + echo Breadcrumbs::widget ([ | ||
262 | + 'homeLink' => [ | ||
263 | + 'label' => '<span itemprop="name">Главная</span>', | ||
264 | + 'url' => ['/'], | ||
265 | + 'template' => "<li itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>{link}<meta itemprop='position' content='1' /></li>", | ||
266 | + 'itemprop' => 'item', | ||
267 | + ], | ||
268 | + 'links' => $links, | ||
253 | 'encodeLabels' => false, | 269 | 'encodeLabels' => false, |
270 | + 'options' => [ | ||
271 | + 'itemscope' => true, | ||
272 | + 'itemtype' => 'http://schema.org/BreadcrumbList', | ||
273 | + ], | ||
254 | ]) | 274 | ]) |
255 | ?> | 275 | ?> |
256 | - | ||
257 | - | ||
258 | <div class="both"></div> | 276 | <div class="both"></div> |
259 | - </nav></span> | 277 | + </nav> |
260 | <?php endif; ?> | 278 | <?php endif; ?> |
261 | <?= $content ?> | 279 | <?= $content ?> |
262 | </div> | 280 | </div> |