Can someone please help me out, I’m totally stuck! I don’t know how to add a class name to <li> tag in Zend navigation XML
This is my XML
<configdata>
<nav>
<home>
<label>Home </label>
<uri>/</uri>
</home>
<request>
<label>Quotes </label>
<uri>/quote</uri>
</request>
<work>
<label>How It Works</label>
<uri>/how-it-works</uri>
</work>
<information>
<label>Informations </label>
<uri>/informations</uri>
</information>
<directory>
<class> last </class>
<label>Directory </label>
<uri>/directory</uri>
</directory>
</nav>
</configdata>
When I add <class>last</class> this is what i get:
<li>
<a class="last" href="/directory">Directory </a>
</li>
Currently I’m getting <a class="last"> but I need <li class="last">
Thanks so much in advance!
Cheers
I think that the best way to put css classes into li elements would be to write your own navigation menu helper, called for example
My_View_Helper_NavigationMenuthat extends originalZend_View_Helper_Navigation_Menuclass. For this reason I prepared an example of such a helper that overloads_renderMenu()method. The code of the method seems long, but this is because original code is long. There are only few new/modified lines in overloaded_renderMenu():File: APPLICATION_PATH/views/helpers/NavigationMenu.php
In your layout.phtml you need to indicate to the navigation view helper to use this new class. You can do this as follows:
Finally in your navigation.xml you could define a class for a li element using liclass tag (you can use whatever name you want for this tag):
Hopefully this will be helpful to you. Ideally, I should have named the new class
My_View_Helper_Navigation_Menu(located in APPLICATION_PATH/views/helpers/Navigation/Menu.php). However, I could not make Zend plugin loaders to load it and I went withMy_View_Helper_NavigationMenu.