<?phpfunction phptemplate_menu_item($mid, $children = '', $leaf = TRUE) {
$link = menu_item_link($mid);
$css_id = strtolower(str_replace(' ', '_', strip_tags($link)));
return '<li id="' . $css_id . '" class="' . ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .'">'. $link . $children ."</li>\n";
}?>li#my_account a{
background-image:url(../mytotallysweeticons/my_account.png);
}For users of the Framework Theme in English
Thanks to SteveJB for the following contribution.
For users of the framework theme (or any theme that by default) adds odd and even classes.
Replace (found at the bottom of the packaged template.php)
function phptemplate_menu_item($mid, $children = '', $leaf = true) {
static $count = 0;
$zebra = ($count % 2) ? 'odd' : 'even';
$count++;
return '<li class="' . ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .' ' . $zebra . '">'. menu_item_link($mid) . $children ."</li>\n";
}function phptemplate_menu_item($mid, $children = '', $leaf = TRUE) {
static $count = 0;
$zebra = ($count % 2) ? 'odd' : 'even';
$count++;
$link = menu_item_link($mid);
$css_id = strtolower(str_replace(' ', '_', strip_tags($link)));
return '<li id="' . $css_id . '" class="' . ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .' ' . $zebra . '">'. menu_item_link($mid) . $children ."</li>\n";
}If you have a language other than English (say, Chinese), then you would have something like the following:
<li id="Chinese-characters" class="leaf"><?php
function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
$search = array(' ','.');
$css_id = strtolower(str_replace($search, '_', strip_tags($link)));
return '<li id="' . $css_id . '" class="' . ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf')) .'">'. $link . $children ."</li>\n";
}?>Add odd even class to menu item
update your template.php then add preferred style to css
/* add item-odd item-even class to list */
function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
static $count = 0;
$zebra = ($count % 2) ? 'odd' : 'even';
$count++;
$class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
if (!empty($extra_class)) {
$class .= ' '. $extra_class;
}
if ($in_active_trail) {
$class .= ' active-trail';
}
$class .= ' item-'. $zebra;
return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
}
No comments:
Post a Comment