Skip to content

Instantly share code, notes, and snippets.

@mareksotak
Created July 14, 2011 22:14
Show Gist options
  • Save mareksotak/1083600 to your computer and use it in GitHub Desktop.
Save mareksotak/1083600 to your computer and use it in GitHub Desktop.
Add span to first level items only
<?php
function mytheme_preprocess_menu_link__main_menu(&$vars) {
// first level
if ($vars['element']['#original_link']['plid'] == 0) {
$vars['first_level'] = 1;
if ($vars['element']['#original_link']['in_active_trail']) {
$vars['active'] = 1;
}
}
}
function mytheme_menu_link__main_menu($variables) {
$element = $variables['element'];
$sub_menu = '';
// the $variables['first_level'] will be populated if it is a first level menu!
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment