Adding a span tag to main menu and nice menu sub items in drupal 7
Component ID
2376823
Component name
Adding a span tag to main menu and nice menu sub items in drupal 7
Component type
theme
Maintenance status
Development status
Component security advisory coverage
not-covered
Component created
Component changed
Component body
function THEME_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
$switch = $element['#original_link']['has_children'];
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$element['#localized_options']['html'] = TRUE;
#This adds the span only to the parent Title: If you need the span on all text Titles Just remove the if else statement and leave $linktext = '<span class="your_class">' . $element['#title'] . '</span>'; :
if($switch == 1) {
$linktext = $element['#title'] . '<span class="your_class"> </span>';
} else {
$linktext = $element['#title'];
}
$output = l($linktext, $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>
";
}