1

The requirement is to remove some default blocks when my custom module is enabled. So how could I remove this blocks using the admin setting configuration values. I am not creating a block that should be shown based on configuration. I want to remove already added block in default layouts.

1
  • 1
    I want to remove default block conditionally, not my custom block Feb 28, 2017 at 7:32

2 Answers 2

1

Found a better solution :

        <referenceBlock name="<YOUR_RFERENCE_BLOCK>">
            <action method="unsetChild" ifconfig="{module}/{section}/enabled">
                <argument name="block" xsi:type="string">BLOCK_NAME_YOU_WANT_TO_REMOVE</argument>
            </action>
        </referenceBlock>
-1
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="<YOUR-BLOCK-NAME>">
            <referenceBlock name="general" remove="true" ifconfig="{module}/{section}//enable" />
        </referenceBlock>
    </body>
</page>
2
  • 1
    This is not working. It's removing the block regardless of the configuration settings. Feb 28, 2017 at 7:43
  • Check now new answer
    – Jackson
    Feb 28, 2017 at 7:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.