When I create a new page in Magento 2 using the "two columns with left bar" layout it by default puts the wishlist in there.
Using the "layout update XML" in the design options tab I can remove that using this:
<referenceBlock name="wishlist_sidebar" remove="true"/>
What I also want to do is replace it with my own static block. I thought something like the following would do the trick but it does not. Can someone help?
<container name="sidebar.additional">
<block class="Magento\Cms\Block\Block" name="test" />
</container>
2 Answers 2
To reference a container you need to use referenceContainer as opposite to referenceBlock to reference a block.
The container tag is used to create a container as the block tag is used to create a block.
In your case, the right code would be:
<referenceContainer name="sidebar.additional">
<block class="Magento\Cms\Block\Block" name="test">
<arguments>
<argument name="block_id" xsi:type="string">test</argument>
</arguments>
</block>
</referenceContainer>
This is assuming your cms block id is test, you'll need to replace that value in case it is different
-
Is it's necessary to put block class="Magento\Cms\Block\Block" name="test"> ??Arunendra– Arunendra2016年04月13日 13:33:05 +00:00Commented Apr 13, 2016 at 13:33
-
@Arunendra yes it is requiredRaphael at Digital Pianism– Raphael at Digital Pianism2016年04月13日 13:33:51 +00:00Commented Apr 13, 2016 at 13:33
-
Thank you all for the solution! Does anyone know if it is possible to add a css class / div wrapper to the block using XML? Or is the best way to just wrap the contents of the block in a div manually?caffeinehigh– caffeinehigh2016年04月13日 14:14:07 +00:00Commented Apr 13, 2016 at 14:14
-
@user1837290 please ask a different question for that, it'll have a better visibility and you'll get help easilyRaphael at Digital Pianism– Raphael at Digital Pianism2016年04月13日 14:17:31 +00:00Commented Apr 13, 2016 at 14:17
-
weird. This works on one of my installs, but it doesnt work on the other! SHM!styzzz– styzzz2017年12月07日 15:36:14 +00:00Commented Dec 7, 2017 at 15:36
It should work like this
<referenceContainer name="sidebar.additional">
<block class="Magento\Cms\Block\Block" name="test">
<arguments>
<argument name="block_id" xsi:type="string">promo</argument>
</arguments>
</block>
</referenceContainer>