Engine23

Magento - getChildrenWrapClass

I just wasted 3 hours of my life trying to set this value in xml.

Normally you think that in a Block when you see $this->getChildrenWrapClass() that the value for that would come from xml or in an observer where that value is being set by $block->setChildrenWrapClass(), however for this you would be totally mistaken.

<reference name="catalog.topnav.renderer">
<action method="setData"><name>setChildrenWrapClass</name><value>abc123</value></action>
<action method="setData"><name>children_wrap_class</name><value>321cba</value></action>
<action method="setChildrenWrapClass"><value>ecreameryTest</value></action>
</reference>

That was all the different types of xml I was trying to use to get that value set!

Well, it turns out this is actually a parameter that is passed into getHtml()

Sigh

This is actually found on a template file

template/page/html/topmenu.phtml 

<?php $_menu=$this->getHtml('level-top','yourValueGoesHere') ?>

<?php if($_menu): ?>
<nav id="nav">
<ol class="nav-primary">
<?phpecho$_menu?>
</ol>
</nav>
<?php endif ?>

Basically, if you want your category navigation to have a div around the sub navigation <ul> you pass in that second argument.  Lesson learned, not everything in Magento is XML sometimes it is just plain on PHP.

Share: