1

We have a custom template file and want to display it on all the pages except the checkout page. However, it shows even in checkout page. We have used the below code in our theme default.xml.

<container name="footer.newsletter" htmlTag="div" htmlClass="home-newsletter textcenter white-text" after="home.customers">
                <block class="Magento\Newsletter\Block\Subscribe" name="form.subscribe.home" template="Magento_Newsletter::subscribe.phtml" ifconfig="newsletter/general/active"/>
            </container>

Can anyone please help me on how to remove it from checkout page?

4

Add your block in default.xml and in checkout_index_index.xml write below code:

<referenceBlock name="form.subscribe.home" remove="true" />

Hope it solve your issue.

0

In more recent versions of Magento2, the remove method is now:

<referenceBlock name="block_name" remove="true"/>

Example: Remove newsletter in block on page and footer links block on page

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<body>
     <referenceBlock name="form.subscribe" remove="true" />
     <referenceBlock name="footer_links" remove="true" />
</body>
</page>

The steps I mention above is the shortest process for you to Remove Block in Layout in Magento 2.

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.