我试图在产品类别页面上添加面包屑,也在产品详细信息页面上添加以下代码,但它不起作用 .
1. Add following code to theme default.xml and check page.top is not remove
<referenceContainer name="page.top">
<block class="Magento\Theme\Block\Html\Breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>
</referenceContainer>
2. add fallowing code to catalog_category_view.xml
<referenceBlock name="breadcrumbs">
<action method="addCrumb">
<argument name="crumbName" xsi:type="string">Home</argument>
<argument name="crumbInfo" xsi:type="array">
<item name="title" xsi:type="string">Home</item>
<item name="label" xsi:type="string">Home</item>
<item name="link" xsi:type="string">{{baseUrl}}</item>
</argument>
</action>
<action method="addCrumb">
<argument name="crumbName" xsi:type="string">Register</argument>
<argument name="crumbInfo" xsi:type="array">
<item name="title" xsi:type="string">Register</item>
<item name="label" xsi:type="string">Register</item>
</argument>
</action>
</referenceBlock>
3. Add following code to list.phtml
<?php echo $this->getLayout()->getBlock('breadcrumbs')->toHtml(); ?>
以上所有代码均无效 .