Community Documentation

theme_menu_item

5 menu.inc theme_menu_item($mid, $children = '', $leaf = TRUE)
6 menu.inc theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL)

Generate the HTML output for a menu item and submenu.

Related topics

File

includes/menu.inc, line 1151
API for the Drupal menu system.

Code

<?php
function theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
  $class = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
  if (!empty($extra_class)) {
    $class .= ' ' . $extra_class;
  }
  if ($in_active_trail) {
    $class .= ' active-trail';
  }
  return '<li class="' . $class . '">' . $link . $menu . "</li>\n";
}
?>

Comments

This function has been

This function has been renamed to theme_menu_link() in Drupal 7.

Adding something changed to

Warning: different modules like Special menu items and similar could override menu functions like this one, resulting in ignorance towards template.php altering.

theming menu items element

for D6. how do i theme each item element specifically "

  • " tag... i wanted to add some "css class" on the first and last item. while the rest of the elements are just simply clean "
  • " tags...
  • please help...

    Login or register to post comments