You are here

function admin_menu_add_item in Administration menu 5.2

Same name and namespace in other branches
  1. 5.3 admin_menu.module \admin_menu_add_item()

Add a custom menu item.

Parameters

array $_admin_menu: An array containing the complete administration menu structure, passed by reference.

int $pid: The parent menu item id.

array $item: An menu item array for the menu system. May contain the key 'weight' to adjust the item's weight. You can use Devel module to display additional information about menu items.

Return value

int The id of the new menu item.

3 calls to admin_menu_add_item()
admin_menu_adjust_items in ./admin_menu.inc
Add some hard-coded features for better user experience.
admin_menu_admin_menu in ./admin_menu.module
Implementation of hook_admin_menu().
admin_menu_copy_items in ./admin_menu.inc
Recursively copy menu items from a source parent menu item to a target item.

File

./admin_menu.module, line 362
Renders a menu tree for administrative purposes as dropdown menu at the top of the window.

Code

function admin_menu_add_item(&$_admin_menu, $pid, $item) {
  if (empty($item['path'])) {
    return FALSE;
  }
  $item['pid'] = $pid;
  $item['children'] = array();
  $id = max(array_keys($_admin_menu)) + 1;
  $_admin_menu[$id] = $item;
  $_admin_menu[$pid]['children'][] = $id;
  $_admin_menu['index'][$item['path']] = $id;
  admin_menu_item_url($_admin_menu, $id);
  return $id;
}