6

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.

7

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>
  • 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 Jun 2 '16 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 – Raphael at Digital Pianism Jun 2 '16 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? – bhargav shastri Oct 2 '18 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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