By GarbageXAY1979 on
Hey all, I am trying to customize the HTML generated when building a menu from primary links.
I have the following copied code inside template.php (which resides in my theme directory):
function phptemplate_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 = "$class $extra_class";
}
if ($in_active_trail){
$class = "$class active-trail";
}
$class .= ' '.preg_replace('/[^a-zA-Z0-9]/', '', strtolower(strip_tags($link)));
return '<li class="'. $class .'"><span>'. $link . $menu ."</span></li>\n";
}
Do I have to register the method somewhere? My theme is called 'pcspectra' and I have tried renaming the method to 'pcspectra_menu_item' with no difference.
Can someone please tell me what I am doing wrong???
Cheers,
Alex
Comments
Wrong function, you need to
Wrong function, you need to override theme_links for primary links - see this http://bit.ly/cE71id
Avoid using the phptemplate_ prefix for theme and preprocess functions, use themename_ instead. In D7 you can't even use the phptemplate_ prefix anymore, so best practice is not to.
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Cool
Thank you for the reply :)
Cheers,
Alex
Did that work for you? I'm
Sorry, didn't realize this was a D6 thread -- forgot what year it is!
its a D7 thread now
phptemplate_menu_item() doesn't work in D7. Is there a suitable alternative to use in D7 which will assign and uniquely name menu leafs based on the menu item title?