In Magento 1 I could remove a block added by a layout file by adding this in my layout-block
<remove ="block_id_here" />
How can I do the same for Magento 2?
As a practical exercise, let's say I have my own module from which I want to remove the dashboard block from the admin dashboard page.
The block is added from app/code/Magento/Backend/view/adminhtml/layout/adminhtml_dashboard_index.xml
using this:
<referenceContainer name="content">
<block class="Magento\Backend\Block\Dashboard" name="dashboard"/>
</referenceContainer>
I assume I need to create the file view/adminhtml/layout/adminhtml_dashboard_index.xml
in my module, but what do I need to put in it?
Best Answer
In more recent versions of Magento2, the remove method is now:
<referenceBlock name="block_name" remove="true"/>
Example:
This is important to know in case you are trying to do something more than just remove an element. Changing the namespace to layout instead of
page_configuration
may not allow you to do everything you are needing to do.