Skip to main content
Magento

Return to Question

replaced http://magento.stackexchange.com/ with https://magento.stackexchange.com/
Source Link

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.

Tweeted twitter.com/StackMagento/status/837978321937960961
Source Link
Marius
  • 198.8k
  • 55
  • 431
  • 837

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.

default

AltStyle によって変換されたページ (->オリジナル) /