Drupal: Menu Functions
In this article, I would tell you about Drupal menu functions:
Name | Description | Code |
drupal_help_arg | Creates elements for $arg array in hook_help() | drupal_help_arg($arg = array()) |
menu_cache_clear | Clears cache for one menu element | menu_cache_clear($menu_name = 'navigation') |
menu_cache_clear_all | Clears all cached menu data. It has to be called every time the changes could be made in menu hierarchy or menu links | menu_cache_clear_all() |
menu_execute_active_handler | Implements a function which is associated with a current path | menu_execute_active_handler($path = NULL) |
menu_get_active_breadcrumb | Gets breadcrumbs defined by an active path for a current page | menu_get_active_breadcrumb() |
menu_get_active_help | Returns help related to an active menu item | menu_get_active_help() |
menu_get_active_menu_name | Gets and active menu for a current page – defines an active path | menu_get_active_menu_name() |
menu_get_active_title | Gets a heading of a current page (as defined by an active path) | menu_get_active_title() |
menu_get_active_trail | Gets an active trail of a current page – a path to the root in menu tree | menu_get_active_trail() |
menu_get_ancestors | Returns the ancestors (and relevant placeholders) for any given path. | menu_get_ancestors($parts) |
menu_get_item | Gets router item | menu_get_item($path = NULL, $router_item = NULL) |
menu_get_names | Builds a list of menu names | menu_get_names($reset = FALSE) |
menu_get_object | Returns an object from menu router | menu_get_object($type = 'node', $position = 1, $path = NULL) |
menu_link_children_relative_depth | Finds depth of an item child items relatively to the item depth | menu_link_children_relative_depth($item) |
menu_link_delete | Remove one or more menu items | menu_link_delete($mlid, $path = NULL) |
menu_link_load | Returns menu item by its identifier (mlid), verifying access and translating heading and description. Such item is ready for rendering and output. | menu_link_load($mlid) |
menu_link_maintain | Inserts, renews or deletes uncustomized menu link related to a module | menu_link_maintain($module, $op, $link_path, $link_title) |
menu_link_save | Saves menu link | menu_link_save(&$item) |
menu_list_system_menus | Returns array with names of the system (default) menus. | menu_list_system_menus() |
menu_local_tasks | Gathers local tasks (tabs) for a specified level | menu_local_tasks($level = 0, $return_root = FALSE) |
menu_navigation_links | Returns and array of links for menu navigation | menu_navigation_links($menu_name, $level = 0) |
menu_path_is_external | Returns TRUE if path is external | menu_path_is_external($path) |
menu_primary_links | Returns links array to show “Main links” menu | menu_primary_links() |
menu_primary_local_tasks | Returns arranged local tasks for the top level | menu_primary_local_tasks() |
menu_rebuild | (Re-)fill database tables used by different menu items | menu_rebuild() |
menu_router_build | Collects, changes and stores menu definitions and items definitions | menu_router_build($reset = FALSE) |
menu_secondary_links | Returns an array of links which should be displayed as Additional links | menu_secondary_links() |
menu_secondary_local_tasks | Returns arranged local tasks of the second level | menu_secondary_local_tasks() |
menu_set_active_item | Sets and active path which defines the loaded page | menu_set_active_item($path) |
menu_set_active_menu_name | Sets (or gets) an active menu for a current page determining an active trail | menu_set_active_menu_name($menu_name = NULL) |
menu_set_active_trail | Sets (or gets) and active trail for a current page – a path to the root in menu tree | menu_set_active_trail($new_trail = NULL) |
menu_set_item | Changes statistically cached item of a specified path | menu_set_item($path, $router_item) |
menu_tab_root_path | Returns the router path, or the path of the parent tab of a default local task. | menu_tab_root_path() |
menu_tree | Renders menu tree taking into account current path | menu_tree($menu_name = 'navigation') |
menu_tree_all_data | Gets data of a structure which present name of a menu tree | menu_tree_all_data($menu_name = 'navigation', $item = NULL) |
menu_tree_check_access | Checks access and implements other dynamic operations for every link in menu tree | menu_tree_check_access(&$tree, $node_links = array()) |
menu_tree_collect_node_links | Additional recursive function. Collects links to nodes | menu_tree_collect_node_links(&$tree, &$node_links) |
menu_tree_data | Builds data for the menu tree | menu_tree_data($result = NULL, $parents = array(), $depth = 1) |
menu_tree_output | Returns menu tree for output | menu_tree_output($tree) |
menu_tree_page_data | Gets the data structure representing a named menu tree, based on the current page. | menu_tree_page_data($menu_name = 'navigation') |
menu_unserialize | The menu system uses serialized arrays stored in the database for arguments. However, often these need to change according to the current path. This function unserializes such an array and does the necessary change. | menu_unserialize($data, $map) |
menu_valid_path | Validates path of a link to created or edited men item | menu_valid_path($form_item) |
theme_menu_item | Generates HTML code for menu item and submenu item | theme_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) |
theme_menu_item_link | Generates HTML data output for a single menu item | theme_menu_item_link($link) |
theme_menu_local_task | Creates HTML for a link for one local task (draws a tab) | theme_menu_local_task($link, $active = FALSE) |
theme_menu_local_tasks | Returns the rendered local tasks. The default implementation renders them as tabs. | theme_menu_local_tasks() |
theme_menu_tree | Generates HTML-code to be output for menu tree | theme_menu_tree($tree) |
_menu_check_access | Check access rights for menu item using callback access | _menu_check_access(&$item, $map) |
_menu_clear_page_cache | Helper function to clear the page and block caches at most twice per page load | _menu_clear_page_cache() |
_menu_delete_item | Additional function for menu_link_delete; removes one menu link | _menu_delete_item($item, $force = FALSE) |
_menu_find_router_path | Finds the router path which will serve this path | _menu_find_router_path($link_path) |
_menu_item_localize | Localizes the router item title using another callback. | _menu_item_localize(&$item, $map, $link_translate = FALSE) |
_menu_link_build | Creates a link from router element | _menu_link_build($item) |
_menu_link_map_translate | This function translates the path elements in the map using any to_arg helper function. These functions take an argument and return an object. | _menu_link_map_translate(&$map, $to_arg_functions) |
menu_link_move_children | Renews child elements of a moving menu item | _menu_link_move_children($item, $existing_item) |
_menu_link_parents_set | Helper function that sets the p1..p9 values for a menu link being saved. | _menu_link_parents_set(&$item, $parent) |
_menu_link_translate | This function is similar to _menu_translate() but does link-specific preparation such as always calling to_arg functions. | _menu_link_translate(&$item) |
_menu_load_objects | Loads objects defined in $item[‘load_functions’] into a map. | _menu_load_objects(&$item, &$map) |
_menu_navigation_links_rebuild | Helper function to build menu links for the items in the menu router. | _menu_navigation_links_rebuild($menu) |
_menu_router_build | Helper function to build the router table based on the data from hook_menu. | _menu_router_build($callbacks) |
_menu_router_cache | Helper function to store the menu router if we have it in memory. | _menu_router_cache($new_menu = NULL) |
_menu_set_expanded_menus | Helper function to update a list of menus with expanded items | _menu_set_expanded_menus() |
_menu_site_is_offline | Checks if a site is in maintenance mode | _menu_site_is_offline() |
_menu_translate | Handles dynamic path translation and menu access control. | _menu_translate(&$router_item, $map, $to_arg = FALSE) |
_menu_tree_check_access | Recursive helper function for menu_tree_check_access() | _menu_tree_check_access(&$tree) |
_menu_tree_cid | Helper function – compute the real cache ID for menu tree data. | _menu_tree_cid($menu_name, $data) |
_menu_tree_data | Recursive helper function to build the data representing a menu tree. | _menu_tree_data($result, $parents, $depth, $previous_element = '') |
_menu_update_parental_status | Checks and renews ‘has_children’ status for a parent link | _menu_update_parental_status($item, $exclude = FALSE) |