Hello,

I need set CSS class only for first level <LI> in menu. There is function "theme_menu_item", but I don´t know which $link is first level. What`s right solution?

Thanks for any suggestions,

Fery

Comments

Anonymous’s picture

Would this be the solution to your problem ?

http://drupal.org/node/138656

______________________________

www.raincitystudios.com

Fery’s picture

I need something else.

Other class for all LI in first level ul.menu. /Drupal 6.X/

puleddu’s picture

I appreciate help on the same topic!
Anybody could help?

Thank you a lot!

---
Antonio
http://taldeitali.it

Anonymous’s picture

/**
 * Implementation of theme_menu_item().
 *
 * Add active class and custom id to current menu item links.
 */



function phptemplate_menu_item($mid, $children = '', $leaf = TRUE) {
  $item = menu_get_item($mid); // get current menu item
  // decide whether to add the active class to this menu item
  if ((drupal_get_normal_path($item['path']) == $_GET['q']) // if menu item path...
  || (drupal_is_front_page() && $item['path'] == '<front>')) { // or front page...
    $active_class = ' active'; // set active class
  } else { // otherwise...
    $active_class = ''; // do nothing
  }
  $attribs = isset($item['description']) ?
array('title' => $item['description']) : array();
  $replace = array(' ', '&');
  $attribs['id'] = 'menu-'. str_replace($replace, '-', strtolower($item['title']));
  return
'
<li class="'. ($leaf ? 'leaf' : ($children ? 'expanded' : 'collapsed')) .
$active_class .'" id="'. $attribs['id'] . '">' .
menu_item_link($mid) . $children ."</li>
\n";
}