-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbreadcrumbs.phtml
44 lines (42 loc) · 1.48 KB
/
breadcrumbs.phtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php if ($crumbs && is_array($crumbs)): ?>
<div class="breadcrumbs">
<ul class="items">
<?php foreach ($crumbs as $crumbName => $crumbInfo): ?>
<li class="item <?= $block->escapeHtmlAttr($crumbName) ?>">
<?php if ($crumbInfo['link']): ?>
<a href="<?= $escaper->escapeUrl($crumbInfo['link']) ?>"
title="<?= $escaper->escapeHtml($crumbInfo['title']) ?>">
<?= $escaper->escapeHtml($crumbInfo['label']) ?>
</a>
<?php elseif ($crumbInfo['last']): ?>
<strong><?= $escaper->escapeHtml($crumbInfo['label']) ?></strong>
<?php else: ?>
<?= $escaper->escapeHtml($crumbInfo['label']) ?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php if ($crumbs && is_array($crumbs)): ?>
<script type="application/ld+json">
{
<?php $position = 1; ?>
"@context": "http://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
<?php foreach ($crumbs as $crumbName => $crumbInfo): ?>
{
"@type": "ListItem",
"position": "<?= $escaper->escapeHtml($position++) ?>",
"item": {
"@id": "<?= $escaper->escapeUrl($crumbInfo['link']) ?>",
"name": "<?= $escaper->escapeHtml($crumbInfo['label']) ?>"
}
}
<?= $crumbInfo['last'] ? '' : ',' ?>
<?php endforeach; ?>
]
}
</script>
<?php endif; ?>