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 | 29 | //foreach($category->getParents()->all() as $parent) { |
30 | 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 | 36 | $this->registerCssFile (Yii::getAlias('@web/css/ion.rangeSlider.css')); | ... | ... |
frontend/views/layouts/main.php
... | ... | @@ -241,22 +241,40 @@ $this->registerJs(" |
241 | 241 | <?= $this->render('main-menu')?> |
242 | 242 | <div class="both"></div> |
243 | 243 | </div> |
244 | - | |
245 | 244 | <div class="wrapper_all"> |
246 | 245 | <?php if(isset ($this->params['breadcrumbs'])):?> |
247 | - <span itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> | |
248 | 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 | 269 | 'encodeLabels' => false, |
270 | + 'options' => [ | |
271 | + 'itemscope' => true, | |
272 | + 'itemtype' => 'http://schema.org/BreadcrumbList', | |
273 | + ], | |
254 | 274 | ]) |
255 | 275 | ?> |
256 | - | |
257 | - | |
258 | 276 | <div class="both"></div> |
259 | - </nav></span> | |
277 | + </nav> | |
260 | 278 | <?php endif; ?> |
261 | 279 | <?= $content ?> |
262 | 280 | </div> | ... | ... |