NiceMenus Theme Functions in 7.x & 6.x

Last updated on
30 April 2025

Drupal 6 & 7 uses version 2 of Nice Menus . These have changed in version 2.x. Theme functions can be called using nice_menus, with the "s"on the end.

theme_nice_menu($id, $menu_name, $mlid, $direction = 'right', $menu = NULL)

$id
The nice menu ID. You can find the ID for a particular block you have created by going to Administer > Structure > Blocks (example.com/admin/structure/block) and hovering over the "configure" link (e.g. example.com/admin/structure/block/manage/nice_menus/1/configure). The $id for the theme function is the number just before '/configure'.

$menu_name
The top parent menu name from which to build the full menu. You can find a menu name by going to Administer > Structure > Menus and clicking to view the list of menu items. The URL for that page contains the menu name (e.g. example.com/admin/structure/menu/manage/menu-custom). In this example, the $menu_name would be 'menu-custom'.

$mlid
The menu ID from which to build the displayed menu. If you use NULL here, then the whole menu will be displayed. If you only want a subset from the menu, then you can enter the menu id for the top item to use. You can find the menu id for any menu item by going to Administer > Site Building > Menus, click the menu name of the list you want to see, then hover over the edit link for the item (e.g. example.com/admin/structure/menu/manage/menu-custom/edit). The $mlid for this item would be the string or number just before '/edit' - in this example, menu-custom.

$direction
Optional. The direction the menu expands. Default is 'right'. Other options are 'down' and 'left'.

$menu
Optional. A custom menu array to use for theming -- it should have the same structure as that returned by menu_tree_all_data(). Default is the standard menu tree.

Calling the Function

Will print out the navigation menu (Drupal core's admin menu) but only starting with menu item # 17, which is the Site Building item, using dropdowns. The menu will be printed out in the 'content' region of the theme.

$menu = theme('nice_menu', 1, 'navigation', 17, 'down');
print $menu['content'];

Will print out the entire menu named "menu-custom" flying out to the left.

$menu = theme('nice_menu', 1, 'menu-custom', NULL, 'left');
print $menu['content'];

Helper functions for main/secondary menus.

There are also helper functions which provide wrappers around theme_nice_menu() to make it easier to display those in your theme.

This will print out the main menu:
print theme('nice_menus_main_menu');

This will print out the secondary menu:
print theme('nice_menus_secondary_menu');

Help improve this page

Page status: Not set

You can: