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
Ben Crook
15.8k4 gold badges53 silver badges105 bronze badges
2 Answers 2
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
Raphael at Digital Pianism
70.8k37 gold badges192 silver badges357 bronze badges
-
1Hmmm 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– Ben Crook2016年06月02日 14:54:08 +00:00Commented 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 outRaphael at Digital Pianism– Raphael at Digital Pianism2016年06月02日 15:07:53 +00:00Commented 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?bhargav shastri– bhargav shastri2018年10月02日 10:53:30 +00:00Commented Oct 2, 2018 at 10:53
I use without action tag:
<referenceBlock name="navigation.sections">
<arguments>
<argument name="group_css" xsi:type="string"/>
</arguments>
</referenceBlock>
default