5

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>
asked Apr 13, 2016 at 13:24

2 Answers 2

10

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

answered Apr 13, 2016 at 13:29
5
  • Is it's necessary to put block class="Magento\Cms\Block\Block" name="test"> ?? Commented Apr 13, 2016 at 13:33
  • @Arunendra yes it is required Commented 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? Commented 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 easily Commented Apr 13, 2016 at 14:17
  • weird. This works on one of my installs, but it doesnt work on the other! SHM! Commented Dec 7, 2017 at 15:36
2

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>
answered Apr 13, 2016 at 13:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.