Last active
October 13, 2015 10:27
-
-
Save sardbaba/4181515 to your computer and use it in GitHub Desktop.
Drupal | Omega | Transform the main menu into a select to be used into small screen sizes.
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
// see also https://gist.github.com/3201854 | |
function mytheme_menu_tree__main_menu($variables) { | |
return '<select class="mobile-main-menu" onchange="location = this.options[this.selectedIndex].value;">' | |
. $variables['tree'] . '</select>'; | |
} | |
function mytheme_menu_link__main_menu($variables) { | |
global $base_url; | |
$e = $variables['element']; | |
$attr = ""; | |
if (isset($e['#localized_options']['attributes']['class'][0]) | |
&& $e['#localized_options']['attributes']['class'][0] == "active-trail") | |
$attr = 'selected="selected"'; | |
$link = $e['#href'] == "<front>" ? $base_url : $base_url . "/" . $e['#href']; | |
return '<option value="' . $link . '" ' . $attr . '>' . $e['#title'] . "</option>"; | |
} | |
//main menu (level 2 sidebar) using the menu block module | |
function mytheme_menu_tree__menu_block__1(&$variables) { | |
return '<ul class="sidebar-menu">' . $variables['tree'] . '</ul>'; | |
} | |
function mytheme_menu_link__menu_block__1($variables) { | |
$element = $variables['element']; | |
$sub_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