The following code will set the class nav on the first level UL
$mainNav = public_nav_main();
$mainNav->setUlClass('nav')->setUlId('main-menu-left');
However im using bootstrap and so want the second level ul to have the class 'dropdown-menu'
I cant seem to find a reference to get this sorted.
Zend is being used as the base structure in the software im using, Omeka. Unfortunately Omeka doesnt have a way to do this natively so I am having to dive into the underlying Zend FW although I dont want to modify that too much as it might be changed.
This is admittedly an ugly hack, but you could do it by processing the output of public_nav_main()
with a regular expression. So in the header.php
file you would replace:
echo public_nav_main();
with
echo preg_replace( "/(?<!\/)ul(?!.*?nav)/", 'ul class="dropdown-menu"', public_nav_main() );
This will only work if you only have 2 levels in your menu, since the above regular expression will also add the class="dropdown-menu"
to all ul
elements below the top level ul
.
public_nav_main()
class
attributes in your 2nd and lower level ul
elements in the event that they already have a class
attribute