10

I want to remove the block from referenceContainer. I have gone through the below link:

Remove block from layout in Magento 2

And tried to remove as per the above answer:

<referenceBlock name="footer-container" remove="true"/>

But it's removing whole container. I want to remove the particular block.

Below is my layout.xml code:

<referenceContainer name="footer-container">
            <block class="Vendor\Module_Name\Block\Template" name="footer_block" template="html/footer.phtml">
                <block class="Magento\Store\Block\Switcher" name="footer.store_switcher" template="switch/stores.phtml"/>
                <block class="Magento\Newsletter\Block\Subscribe" name="footer.newsletter" template="subscribe_footer.phtml"/>
            </block>
        </referenceContainer>

I want to remove only footer.store_switcher and footer.newsletter. I am using the below code to remove both blocks.

<referenceBlock name="footer.store_switcher" remove="true"/>
<referenceBlock name="footer.newsletter" remove="true"/>

default.xml file path:

E:\xampp\htdocs\magento\app\design\frontend\Vender\Theme\Magento_Theme\layout

Please help me.

8
  • you have did right for remove block, after doing last, <referenceBlock name="footer.store_switcher" remove="true"/> <referenceBlock name="footer.newsletter" remove="true"/>not working for you? Mar 14, 2017 at 10:18
  • @RakeshJesadiya could you please elaborate more? I can't understand what you are saying. No both are not working for me. Mar 14, 2017 at 10:22
  • I think you have did right xml code for remove footer.store_switcher and newsletter. May be check after clear cache Mar 14, 2017 at 10:23
  • I have cleared the cache lots of time after write code in xml. Mar 14, 2017 at 10:25
  • you have to do it inside default.xml file not inside layout.xml file Mar 14, 2017 at 10:26

1 Answer 1

20

You can remove using that code:

<referenceContainer name="footer-container" remove="true"/>
<referenceBlock name="form.subscribe" remove="true"/>
2
  • 2
    Lot of help me for today +V
    – Amit Bera
    Jan 24, 2018 at 8:03
  • 1
    Also Use : <referenceBlock name="form.subscribe" remove="true"/> Feb 21, 2019 at 9:43

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.