1

I want to add some other blogs in pages using 2 columns with right bar in pages. For example, I have added code like remove wishlist and I have added my custom block in that Layout Handle in the backend. But it's not working. Please tell me how to fix this.

Layout handle in pages screnshot: https://prnt.sc/i4reka

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="catalog.compare.sidebar" remove="true"/>
        <referenceBlock name="wishlist_sidebar" remove="true"/>
        <referenceContainer name="sidebar.additional">
            <block class="Custom\Blog\Block\Sidebar" name="blog.sidebar" template="Custom_Blog::sidebar.phtml" after="-"/>
        </referenceContainer>      
    </body>
</page>
3

*Magento 2 only support updates of referenceContainer, container, update, move layout tags from admin**.

So, from Layout Update XML section, cannot remove a block
using

<referenceBlock name="{Blockname}" remove="true"/>

So, how to remove a block from Layout Update XML

An Idea ,we do trick, by which we you remove a block from layout

1. First create new container for layout

<container name="removeusedlayout.page" as="removeunsedlayout" label="Remove used use container" htmlTag="div" htmlClass="removeunsedlayout-container" />

2.Move all blocks (which you want remove from layout) to this container to this referenceContainer removeusedlayout.page

<move element="wishlist_sidebar" destination="removeusedlayout.page"/>
  1. Then remove container removeusedlayout.page from layout using below code:
<referenceContainer name="removeusedlayout.pager" remove="true"/>

enter image description here

Output enter image description here

| improve this answer | |
  • There is a typo error (pager instead of page) in your last referenceContainer, isn't there ? – Pol Ravalitera Feb 19 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.