By 00qazs on
Hi,
I want to have menu items with alternating styles, like the $zebra, but I have no idea how to get it to work here. I'm using this to create the menu items:
function phptemplate_menu_item($mid, $children = '', $leaf = true) {
return '<li class="'. ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .'">'. menu_item_link($mid) . $children ."</li>\n";
}
But this returns a list like this:
<li class="leaf">item 1</li>
<li class="leaf">item 2</li>
How can I modify it so it produces something like this:
<li class="odd">item 1</li>
<li class="even">item 2</li>
<li class="odd">item 3</li>
<li class="even">item 4</li>
Thanks for any help.
Comments
This will work
The following version will add odd/even to each menu item (it retains the existing classes also)
Hi, thanks very much!
Hi, thanks very much!
Hello, How would I go about
Hello,
How would I go about modifying this in order to add odd/even to a list generated by a view in a block?
Thanks.
Idan
Hi,
Hi,
You can go to the block.tpl.php file and insert $zebra in the
<div>tag like this:<div <?php print $zebra ?>>[Edit to add <code> and </code> tags: nevets]
Note Drupal 5 already
Note Drupal 5 already include a $block_zebra variable you can use.