File tree 3 files changed +28
-8
lines changed
3 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,17 @@ This module is Hyvä-Ready!
46
46
This module render server-sided product breadcrumbs so it's visible to any robot without requiring any js loads and process.
47
47
Can you still enable the js breadcrumbs so your user can see natural breadcrumbs following their navigation.
48
48
49
+ ## Settings
50
+
51
+ The settings are available at:
52
+
53
+ ` Stores > Configuration > Catalog > Catalog > Search Engine Optimization `
54
+
55
+ - Render Product Breadcrumbs from Server-Side
56
+ - Override Product Breadcrumbs on Client-Side
57
+ - Product Breadcrumbs Strategy
58
+ - Product Breadcrumbs Excluded Categories
59
+
49
60
## Documentation
50
61
51
62
- Toggle server-side product breadcrumbs rendering.
Original file line number Diff line number Diff line change @@ -16,17 +16,18 @@ use Opengento\ProductBreadcrumbs\ViewModel\Product\Breadcrumbs as BreadcrumbsCon
16
16
17
17
/** @var BreadcrumbsConfig $config */
18
18
$ config = $ viewModels ->require (BreadcrumbsConfig::class);
19
+ $ isClientSideRendered = !$ config ->isServerSideRendered () || $ config ->isClientSideOverrideAllowed ();
19
20
?>
20
- <div id="product_breadcrumbs" aria-label="Breadcrumb" role="navigation" x-init="generateProductBreadcrumbsOnProductPage()">
21
+ <div id="product_breadcrumbs" aria-label="<?= $ escaper -> escapeHtmlAttr ( __ ( ' Breadcrumb ' )) ?> " role="navigation"<?= $ isClientSideRendered ? ' x-init="generateProductBreadcrumbsOnProductPage()"' : '' ?> >
21
22
<?php if ($ config ->isServerSideRendered ()): ?>
22
23
<?= $ block ->fetchView ($ block ->getTemplateFile ('Magento_Theme::html/breadcrumbs.phtml ' )) ?>
23
24
<?php endif ; ?>
24
25
</div>
25
- <script>
26
- function generateProductBreadcrumbsOnProductPage() {
27
- <?php if (!$ config ->isServerSideRendered () || $ config ->isClientSideOverrideAllowed ()): ?>
28
- <?php $ breadcrumbsTemplate = '<div id="product_breadcrumbs" aria-label="Breadcrumb" role="navigation"> ' . $ block ->fetchView ($ block ->getTemplateFile ('Magento_Catalog::product/view/breadcrumbs.phtml ' )) . '</div> ' ; ?>
29
- hyva.replaceDomElement('#product_breadcrumbs', '<?= $ escaper ->escapeJs ($ breadcrumbsTemplate ) ?> ');
26
+ <?php if ($ isClientSideRendered ): ?>
27
+ <script>
28
+ function generateProductBreadcrumbsOnProductPage() {
29
+ <?php $ breadcrumbsTemplate = '<div id="product_breadcrumbs" aria-label=" ' . $ escaper ->escapeHtmlAttr (__ ('Breadcrumb ' )) . '" role="navigation"> ' . $ block ->fetchView ($ block ->getTemplateFile ('Magento_Catalog::product/view/breadcrumbs.phtml ' )) . '</div> ' ; ?>
30
+ hyva.replaceDomElement('#product_breadcrumbs', '<?= $ escaper ->escapeJs ($ breadcrumbsTemplate ) ?> ');
31
+ }
32
+ </script>
30
33
<?php endif ; ?>
31
- }
32
- </script>
Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ $config = $block->getData('breadcrumbsConfig');
24
24
$ catalogHelper = $ this ->helper (CatalogHelper::class);
25
25
/** @var BreadcrumbsBlock $breadcrumbs */
26
26
$ breadcrumbs = $ block ->getLayout ()->createBlock (BreadcrumbsBlock::class);
27
+ $ breadcrumbs ->addCrumb (
28
+ 'home ' ,
29
+ [
30
+ 'label ' => __ ('Home ' ),
31
+ 'title ' => __ ('Go to Home Page ' ),
32
+ 'link ' => $ block ->getBaseUrl ()
33
+ ]
34
+ );
27
35
foreach ($ catalogHelper ->getBreadcrumbPath () as $ name => $ crumb ) {
28
36
$ breadcrumbs ->addCrumb ($ name , $ crumb );
29
37
}
You can’t perform that action at this time.
0 commit comments