File tree 5 files changed +54
-9
lines changed
5 files changed +54
-9
lines changed Original file line number Diff line number Diff line change @@ -41,12 +41,10 @@ bin/magento setup:upgrade
41
41
42
42
## Features
43
43
44
- This module render server-sided product breadcrumbs so it's visible to any robot without requiring any js loads and process.
45
- Can you still enable the js breadcrumbs so your user can see natural breadcrumbs following their navigation.
44
+ This module is Hyvä-Ready!
46
45
47
- If your store use Hyva theme, this module works out-of-the-box when the breadcrumbs is server-side rendering. If you want
48
- to print a default breadcrumb then override it with client-side rendering, you need to override the client-side rendered
49
- breadcrumbs template and update the script.
46
+ This module render server-sided product breadcrumbs so it's visible to any robot without requiring any js loads and process.
47
+ Can you still enable the js breadcrumbs so your user can see natural breadcrumbs following their navigation.
50
48
51
49
## Documentation
52
50
Original file line number Diff line number Diff line change 9
9
<system >
10
10
<section id =" catalog" >
11
11
<group id =" seo" >
12
- <field id =" render_product_breadcrumbs_server_side" translate =" label comment " type =" select" sortOrder =" 30" showInDefault =" 1" canRestore =" 1" >
12
+ <field id =" render_product_breadcrumbs_server_side" translate =" label" type =" select" sortOrder =" 30" showInDefault =" 1" canRestore =" 1" >
13
13
<label >Render Product Breadcrumbs from Server-Side</label >
14
- <comment >This setting depends of the theme. If your store use Hyva theme, disable client-side breadcrumbs rendering.</comment >
15
14
<source_model >Magento\Config\Model\Config\Source\Yesno</source_model >
16
15
<config_path >catalog/seo/render_product_breadcrumbs_server_side</config_path >
17
16
</field >
18
17
<field id =" override_product_breadcrumbs_client_side" translate =" label comment" type =" select" sortOrder =" 31" showInDefault =" 1" canRestore =" 1" >
19
18
<label >Override Product Breadcrumbs on Client-Side</label >
20
- <comment >If your store use Hyva theme, this setting is by-passed. You may want to enable the Hyva client-side breadcrumbs rendering.</comment >
19
+ <comment >If you enable override and your store use Hyvä theme, you must enable the Hyvä client-side breadcrumbs rendering.</comment >
21
20
<source_model >Magento\Config\Model\Config\Source\Yesno</source_model >
22
21
<config_path >catalog/seo/override_product_breadcrumbs_client_side</config_path >
23
22
</field >
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <!--
3
+ /**
4
+ * Copyright © OpenGento, All rights reserved.
5
+ * See LICENSE bundled with this library for license details.
6
+ */
7
+ -->
8
+ <page xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:View/Layout/etc/page_configuration.xsd" >
9
+ <body >
10
+ <referenceBlock name =" product_breadcrumbs" >
11
+ <arguments >
12
+ <argument name =" client_side_rendered_crumbs_template" xsi : type =" string" >Opengento_ProductBreadcrumbs::hyvä/product/breadcrumbs.phtml</argument >
13
+ </arguments >
14
+ </referenceBlock >
15
+ </body >
16
+ </page >
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © OpenGento, All rights reserved.
4
+ * See LICENSE bundled with this library for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ use Hyvä \Theme \Model \ViewModelRegistry ;
9
+ use Magento \Framework \Escaper ;
10
+ use Magento \Theme \Block \Html \Breadcrumbs as BreadcrumbsBlock ;
11
+ use Opengento \ProductBreadcrumbs \ViewModel \Product \Breadcrumbs as BreadcrumbsConfig ;
12
+
13
+ /** @var ViewModelRegistry $viewModels */
14
+ /** @var Escaper $escaper */
15
+ /** @var BreadcrumbsBlock $block */
16
+
17
+ /** @var BreadcrumbsConfig $config */
18
+ $ config = $ viewModels ->require (BreadcrumbsConfig::class);
19
+ ?>
20
+ <div id="product_breadcrumbs" x-init="generateProductBreadcrumbsOnProductPage()">
21
+ <?php if ($ config ->isServerSideRendered ()): ?>
22
+ <?= $ block ->fetchView ($ block ->getTemplateFile ('Magento_Theme::html/breadcrumbs.phtml ' )) ?>
23
+ <?php endif ; ?>
24
+ </div>
25
+ <script>
26
+ function generateProductBreadcrumbsOnProductPage() {
27
+ <?php if (!$ config ->isServerSideRendered () || $ config ->isClientSideOverrideAllowed ()): ?>
28
+ <?php $ breadcrumbsTemplate = '<div id="product_breadcrumbs"> ' . $ block ->fetchView ($ block ->getTemplateFile ('Magento_Catalog::product/view/breadcrumbs.phtml ' )) . '</div> ' ; ?>
29
+ hyvä.replaceDomElement('#product_breadcrumbs', '<?= $ escaper ->escapeJs ($ breadcrumbsTemplate ) ?> ');
30
+ <?php endif ; ?>
31
+ }
32
+ </script>
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ $viewModel = $block->getData('viewModel');
18
18
$ config = $ block ->getData ('breadcrumbsConfig ' );
19
19
?>
20
20
<?php if ($ config ->isServerSideRendered ()): ?>
21
- <?= $ block ->fetchView ('Magento_Theme::html/breadcrumbs.phtml ' ) ?>
21
+ <?= $ block ->fetchView ($ block -> getTemplateFile ( 'Magento_Theme::html/breadcrumbs.phtml ' ) ) ?>
22
22
<?php else : ?>
23
23
<div class="breadcrumbs"></div>
24
24
<?php endif ; ?>
You can’t perform that action at this time.
0 commit comments