I'm trying to remove a block from a certain page (be it frontend or backend) but only if a certain config flag is set to true.
Let's take an example.
I want to remove the block with the name dashboard from the admin dashboard.
The block is defined in adminhtml_dashboard_index.xml file from the Magento_Backend module:
<referenceContainer name="content">
<block class="Magento\Backend\Block\Dashboard" name="dashboard"/>
</referenceContainer>
Thanks to Adam's answer Thanks to Adam's answer I can do this in the adminhtml_dashboard_index.xml
<body>
<referenceBlock name="dashboard" remove="true" />
</body>
But I want to take it up a notch and remove this block only if the config setting with the path dashboard/settings/remove has the value 1.
A layout xml approach would be awesome, but I will take an observer approach also.
I'm trying to remove a block from a certain page (be it frontend or backend) but only if a certain config flag is set to true.
Let's take an example.
I want to remove the block with the name dashboard from the admin dashboard.
The block is defined in adminhtml_dashboard_index.xml file from the Magento_Backend module:
<referenceContainer name="content">
<block class="Magento\Backend\Block\Dashboard" name="dashboard"/>
</referenceContainer>
Thanks to Adam's answer I can do this in the adminhtml_dashboard_index.xml
<body>
<referenceBlock name="dashboard" remove="true" />
</body>
But I want to take it up a notch and remove this block only if the config setting with the path dashboard/settings/remove has the value 1.
A layout xml approach would be awesome, but I will take an observer approach also.
I'm trying to remove a block from a certain page (be it frontend or backend) but only if a certain config flag is set to true.
Let's take an example.
I want to remove the block with the name dashboard from the admin dashboard.
The block is defined in adminhtml_dashboard_index.xml file from the Magento_Backend module:
<referenceContainer name="content">
<block class="Magento\Backend\Block\Dashboard" name="dashboard"/>
</referenceContainer>
Thanks to Adam's answer I can do this in the adminhtml_dashboard_index.xml
<body>
<referenceBlock name="dashboard" remove="true" />
</body>
But I want to take it up a notch and remove this block only if the config setting with the path dashboard/settings/remove has the value 1.
A layout xml approach would be awesome, but I will take an observer approach also.
Magento 2: Remove block depending on a config setting
I'm trying to remove a block from a certain page (be it frontend or backend) but only if a certain config flag is set to true.
Let's take an example.
I want to remove the block with the name dashboard from the admin dashboard.
The block is defined in adminhtml_dashboard_index.xml file from the Magento_Backend module:
<referenceContainer name="content">
<block class="Magento\Backend\Block\Dashboard" name="dashboard"/>
</referenceContainer>
Thanks to Adam's answer I can do this in the adminhtml_dashboard_index.xml
<body>
<referenceBlock name="dashboard" remove="true" />
</body>
But I want to take it up a notch and remove this block only if the config setting with the path dashboard/settings/remove has the value 1.
A layout xml approach would be awesome, but I will take an observer approach also.