'blogs', 'page callback' => 'blog_page', 'access arguments' => array('access content'), 'type' => MENU_SUGGESTED_ITEM, ); $items['blog/feed'] = array( 'title' => 'RSS feed', 'page callback' => 'blog_feed', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); return $items; } /** * Alter the data being saved to the {menu_router} table after hook_menu is invoked. * * This hook is invoked by menu_router_build(). The menu definitions are passed * in by reference. Each element of the $items array is one item returned * by a module from hook_menu. Additional items may be added, or existing items * altered. * * @param $items * Associative array of menu router definitions returned from hook_menu(). */ function hook_menu_alter(&$items) { // Example - disable the page at node/add $items['node/add']['access callback'] = FALSE; } /** * Alter the data being saved to the {menu_links} table by menu_link_save(). * * @param $item * Associative array defining a menu link as passed into menu_link_save(). */ function hook_menu_link_alter(&$item) { // Example 1 - make all new admin links hidden (a.k.a disabled). if (strpos($item['link_path'], 'admin') === 0 && empty($item['mlid'])) { $item['hidden'] = 1; } // Example 2 - flag a link to be altered by hook_translated_menu_link_alter() if ($item['link_path'] == 'devel/cache/clear') { $item['options']['alter'] = TRUE; } } /** * Alter a menu link after it's translated, but before it's rendered. * * This hook may be used, for example, to add a page-specific query string. * For performance reasons, only links that have $item['options']['alter'] == TRUE * will be passed into this hook. The $item['options']['alter'] flag should * generally be set using hook_menu_link_alter(). * * @param $item * Associative array defining a menu link after _menu_link_translate() * @param $map * Associative array containing the menu $map (path parts and/or objects). */ function hook_translated_menu_link_alter(&$item, $map) { if ($item['href'] == 'devel/cache/clear') { $item['localized_options']['query'] = drupal_get_destination(); } } /** * Inform modules that a menu link has been created. * * This hook is used to notify module that menu items have been * created. Contributed modules may use the information to perform * actions based on the information entered into the menu system. * * @param $link * The $link record saved into the {menu_links} table. * @return * None. * * @see hook_menu_link_update() * @see hook_menu_link_delete() */ function hook_menu_link_insert($link) { // In our sample case, we track menu items as editing sections // of the site. These are stored in our table as 'disabled' items. $record['mlid'] = $link['mlid']; $record['menu_name'] = $link['menu_name']; $record['status'] = 0; drupal_write_record('menu_example', $record); } /** * Inform modules that a menu link has been updated. * * This hook is used to notify module that menu items have been * updated. Contributed modules may use the information to perform * actions based on the information entered into the menu system. * * @param $link * The $link record saved into the {menu_links} table. * @return * None. * * @see hook_menu_link_insert() * @see hook_menu_link_delete() */ function hook_menu_link_update($link) { // If the parent menu has changed, update our record. $menu_name = db_result(db_query("SELECT mlid, menu_name, status FROM {menu_example} WHERE mlid = :mlid", array(':mlid' => $link['mlid']))); if ($menu_name != $link['menu_name']) { db_update('menu_example') ->fields(array('menu_name' => $link['menu_name'])) ->condition('mlid', $link['mlid']) ->execute(); } } /** * Inform modules that a menu link has been deleted. * * This hook is used to notify module that menu items have been * deleted. Contributed modules may use the information to perform * actions based on the information entered into the menu system. * * @param $link * The $link record saved into the {menu_links} table. * @return * None. * * @see hook_menu_link_insert() * @see hook_menu_link_update() */ function hook_menu_link_delete($link) { // Delete the record from our table. db_delete('menu_example') ->condition('mlid', $link['mlid']) ->execute(); } /** * @} End of "addtogroup hooks". */