function simplemenu_get_menu in SimpleMenu 7
Same name and namespace in other branches
- 5 simplemenu.module \simplemenu_get_menu()
- 6.2 simplemenu.module \simplemenu_get_menu()
- 6 simplemenu.module \simplemenu_get_menu()
Render an HTML list of links for a given menu.
1 call to simplemenu_get_menu()
- _simplemenu_add_menu in ./
simplemenu.module - \brief Add the simplemenu variable with the menu to be displayed.
File
- ./
simplemenu.module, line 297 - Creates a simplemenu.
Code
function simplemenu_get_menu() {
variable_set('simplemenu_running', TRUE);
// if a user turned off menu module but SimpleMenu was previously set
// reset variable so a menu appears
$all_menus = array(
variable_get('simplemenu_menu', 'management:0'),
);
drupal_alter('simplemenu_menus', $all_menus);
if (count($all_menus) > 1) {
// if menu is not enable then we cannot have a count other than 1
$menu_titles = menu_get_menus();
$tree = array();
foreach ($all_menus as $full_name) {
list($menu_name, $mlid) = explode(':', $full_name);
$tree[] = array(
'link' => array(
'simplemenu_multi_menu_root' => TRUE,
'mlid' => $mlid,
'menu_name' => $full_name,
'hidden' => FALSE,
'title' => $menu_titles[$menu_name],
'href' => 'admin/settings/simplemenu',
/// ??? -- we should not have a link here
'in_active_trail' => FALSE,
'has_children' => TRUE,
'localized_options' => array(
'attributes' => array(
'class' => 'simplemenu-top-level',
),
),
),
'below' => simplemenu_menu_tree($full_name),
);
}
}
else {
reset($all_menus);
$tree = simplemenu_menu_tree(current($all_menus));
}
// allow other modules to modify the menu tree
drupal_alter('simplemenu_tree', $tree);
$tree = simplemenu_tree_remove_hidden($tree);
// now generate the output
$menu_form = menu_tree_output($tree);
$menu = drupal_render($menu_form);
if (!$menu) {
$menu = '<ul class="menu"><li><a href="' . url('admin/settings/simplemenu') . '">' . t('No menu items found. Try a different menu as the default.') . '</a></li></ul>';
}
// add the id to the UL tag here instead of the JavaScript
// otherwise it could be added to the <div> tag instead...
$pos = strpos($menu, '>');
$menu = str_replace('class="menu', 'class="menu clear-block', substr($menu, 0, $pos)) . ' id="simplemenu"' . substr($menu, $pos);
variable_set('simplemenu_running', FALSE);
return '<div class="simplemenu-block">' . $menu . ' </div>';
}