Magento2 如何在Magento 2中向布局添加小部件?
有没有办法将小部件添加到布局xml中?我知道后端的布局更新,但我想知道是否有一种方法可以像静态块一样添加小部件?您可以通过以下xml添加小部件Magento2 如何在Magento 2中向布局添加小部件?,magento2,Magento2,有没有办法将小部件添加到布局xml中?我知道后端的布局更新,但我想知道是否有一种方法可以像静态块一样添加小部件?您可以通过以下xml添加小部件 <referenceContainer name="content.top"> <block class="Magento\Catalog\Block\Category\Widget\Link" name="demoBlock" template="widget/static_block/default.phtml">
<referenceContainer name="content.top">
<block class="Magento\Catalog\Block\Category\Widget\Link" name="demoBlock" template="widget/static_block/default.phtml">
<action method="setData">
<argument name="id_path" xsi:type="string">category/20</argument>
<argument name="title" xsi:type="string">Demo Category Title</argument>
<argument name="template" xsi:type="string">category/widget/link/link_inline.phtml</argument>
</action>
</block>
</referenceContainer>
类别/20
演示类别标题
category/widget/link/link_inline.phtml
您需要更新以下内容
- 参考容器根据您的需要
- 块类和模板(如果需要更新块的模板)
- setData中的参数