function theme_nice_menu_tree in Nice Menus 6
Same name and namespace in other branches
- 5 nice_menus.module \theme_nice_menu_tree()
Builds the final nice menu.
Parameters
$menu_name: The top-level menu name that contains the menu to use (e.g. navigation or primary-links) for Drupal menus. For custom $menus this is just the name for menu display.
$mlid: The menu ID from which to start building the items, i.e. the parent of the displayed menu.
$menu: Optional. A custom menu array to use for theming -- it should have the same structure as that returned by menu_tree_all_data().
Return value
An HTML string of properly nested nice menu lists.
1 theme call to theme_nice_menu_tree()
- theme_nice_menu in ./
nice_menus.module - General theming function to allow any menu tree to be themed as a nice menu.
File
- ./
nice_menus.module, line 222 - Module to enable CSS dropdown and flyout menus.
Code
function theme_nice_menu_tree($menu_name, $mlid = NULL, $menu = NULL) {
// Load the full menu array.
$menu = isset($menu) ? $menu : menu_tree_all_data($menu_name);
// For custom $menus and menus built all the way from the top-level we
// don't need to "create" the specific sub-menu and we need to get the title
// from the $menu_name since there is no "parent item" array.
// Create the specific menu if we have a mlid.
if (!empty($mlid)) {
// Load the parent menu item.
$item = menu_link_load($mlid);
$title = check_plain($item['title']);
// Narrow down the full menu to the specific sub-tree we need.
for ($p = 1; $p < 10; $p++) {
if ($sub_mlid = $item["p{$p}"]) {
$subitem = menu_link_load($sub_mlid);
// Menu sets these ghetto-ass keys in _menu_tree_check_access().
$menu = $menu[50000 + $subitem['weight'] . ' ' . $subitem['title'] . ' ' . $subitem['mlid']]['below'];
}
}
}
else {
// Get the title from the DB since we don't have it in the $menu.
$result = db_result(db_query("SELECT title FROM {menu_custom} WHERE menu_name = '%s'", $menu_name));
$title = check_plain($result);
}
$output['content'] = '';
$output['subject'] = $title;
if ($menu) {
$output['content'] .= theme('nice_menu_build', $menu);
}
return $output;
}