9

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.

2 Answers 2

10

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>
3
  • 1
    Hmmm I used a modified version of your first version, I remember reading that we shouldn't use action if the same result can be achieved through arguments. So I replaced your action method with arguments and it worked a treat, thank you.
    – Ben Crook
    Commented Jun 2, 2016 at 14:54
  • 1
    @Ben-Space48 yeah good point I think the action tag is going to be deprecated at some point, I've updated my answer to reflect what you pointed out Commented Jun 2, 2016 at 15:07
  • perfect i am able to add new column with above code thanks, but any idea how to remove existing column with xml file? Commented Oct 2, 2018 at 10:53
0

I use without action tag:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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