NiceMenus Theme functions in 5.x

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

Question

Being fairly new to Drupal I do not know how to find the $id and $pid parameters to make theme_nice_menu work on my site. Can you enlighten me?

Answer

$id
The $id argument is the ID of the menu block you want to display. You may define how many different Nice Menus blocks, up to 10, in the settings at Administer > Site configuration > Nice Menus (example.com/admin/settings/nice-menus.) You can find the ID for a particular block you have created by going to Administer > Site building > Blocks (example.com/admin/build/block) and hovering over the "configure" link (e.g. example.com/admin/build/block/configure/nice_menus/1.) The $id for the theme function is that end number.

$pid
The $pid argument is the identifier of the menu item which is the parent of the items you want to display. You may find a menu id by going to Administer > Site building > Menus (example.com/admin/build/menu) and hovering over the edit link of the parent menu item which will end, again with a number (e.g. example.com/admin/build/menu/item/edit/10, giving 10 as the $pid for the Create content menu.)

Calling the function
The function should be called using the theme function and may be called from either the template.php or directly in a template file (like page.tpl.php.)

This example is theming the Nice menu block ID of 1 and just the menu items that belong to the Create content part of the menu and setting the menu direction to down.

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

Help improve this page

Page status: Not set

You can: