I want to wrap my menu link titles in span tags. So I implement the theme_menu_link function in my template.php. However, that doesn't have any effect on menus displayed using Nice Menus. So I need to add a second function. I have to implement the special theme_nice_menus_menu_item_link function just to get the same functionality for my Nice Menus.
My template.php for my test theme ends up looking like this:
function test_menu_link($vars) {
$vars['element']['#title'] = '<span>' . $vars['element']['#title'] . '</span>';
$vars['element']['#localized_options']['html'] = TRUE;
return theme_menu_link($vars);
}
function test_nice_menus_menu_item_link($vars) {
$vars['element']['#title'] = '<span>' . $vars['element']['#title'] . '</span>';
$vars['element']['#localized_options']['html'] = TRUE;
return theme_nice_menus_menu_item_link($vars);
}
Nice Menus should instead work with the standard theme_menu_link function.
Comments
Comment #1
awasson commentedThis looks like a syntax error in your code to me; the $vars argument should be (array $vars) not ($vars).
The code template you should be following is:
Comment #2
xiukun.zhou commentedComment #3
pratip.ghosh commentedWeird, why doesnt my version work?? I wrote something like this :
but the echo never gets executed when any page runs...
Comment #4
rashmit sidhu commentedMake function in your custom module this will print your block name of your menu and replace '-' with '_'.
Replace block name in your theme template.php describe below.
Let me know if you face any query/concern regarding this.
Thanks!
Comment #5
astonvictor commentedI'm closing it because the issue was created a long time ago without any further steps.
if you still need it then raise a new one.
thanks