Created
August 28, 2014 16:37
-
-
Save mherchel/ba36d3979b392b1b51d7 to your computer and use it in GitHub Desktop.
Add level indicator css class to all menu items and menu links within Drupal theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Add level indicator css class to all menu items and menu links. | |
*/ | |
function THEME_menu_link(array $variables) { | |
$element = $variables['element']; | |
$sub_menu = ''; | |
$element['#attributes']['class'][] = 'menu-item menu-item--level' . $element['#original_link']['depth']; | |
$menu_link = 'menu-item-link menu-item-link--level' . $element['#original_link']['depth']; | |
if ($element['#below']) { | |
$sub_menu = drupal_render($element['#below']); | |
} | |
$output = l($element['#title'], $element['#href'], array('attributes' => array('class' => array($menu_link)))); | |
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