Alright Drupal community... I've been at this for more than 20 hours searching and testing and nothing works out!!
I really need your help. I'm trying to theme the menu_item function.

I have the template.php file and it it I read that I can customize my function.

In order to test if it works or not, I'm just changing the class name and looking and the output source code to see if it worked.
I have no problem customizing the menu_tree function but for some reason when I try to do the same with
menu_item, it just doesn't work.

Anybody has an idea?

Here's the code in my template.php file

<?php

function myThemeName_menu_item_link($link) {
  if (empty($link['localized_options'])) {
    $link['localized_options'] = array();
  }

  return l($link['title'], $link['href'], $link['localized_options']);
}

function myThemeName_menu_tree($tree) {
  return '<ul class="menu---">'. $tree .'</ul>';
}


function myThemeName_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";
}


function myThemeName_menu_local_task($link, $active = FALSE) {
  return '<li '. ($active ? 'class="active" ' : '') .'>'. $link ."</li>\n";
}
?>

It keeps calling the genreic theme_menu_item in includes/menu.inc.

Thanks a lot!

Comments

stevensmith007’s picture

OK...
I don't know what I did but it started to work with the code I posted... akward! but very Cool!
Thanks!

DizzyC’s picture

I suppose you are new to drupal (as am i) and you probably encountered the 'clear cache' problem. Am I right? :)
When i started 'playing' around with Drupal it gave me some headaches too. And now, if something doesen't work right away for some (as i think) misterious reason, i always blame it first on the cache :p I do a clear cache and if it still doesen't work... i start looking for my scrue up.
If you are new, i recomend you the 'Devel' module. It comes in very handy (and it also has a 'Clear cache' menu entry at hand ;) )

Cheers!