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.

Fabian Schmengler
66.2k25 gold badges191 silver badges422 bronze badges
asked Jun 2, 2016 at 14:13

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>
answered Jun 2, 2016 at 14:23
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. 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>
answered Mar 29, 2021 at 11:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.