Magento2 – How to Reset XML Block Arguments Such as CSS

csslayoutmagento2xml

I'm wondering how to unset CSS that has been set through the XML, for example:

<block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::html/sections.phtml">
    <arguments>
        <argument name="group_name" xsi:type="string">navigation-sections</argument>
        <argument name="group_css" xsi:type="string">nav-sections</argument>
    </arguments>
</block>

That code is from the Magento Theme module. I would like to remove the group_css argument in my own theme, I do not want .nav-sections to be added to by markup.

Best Answer

What about using the magic setter ?

<referenceBlock name="navigation.sections">
    <action method="setGroupCss">
        <argument name="group_css" xsi:type="string"></argument>
    </action>
</referenceBlock>

Or even better, I'm pretty sure you can use :

<referenceBlock name="navigation.sections">
    <action method="unsGroupCss" />
</referenceBlock>

Alternative without using the action tag:

<referenceBlock name="navigation.sections">
    <arguments>
        <argument name="group_css" xsi:type="string"></argument>
    </arguments>
</referenceBlock>
Related Topic