danielebarchiesi@6: Content types. danielebarchiesi@6: // The key denotes the dynamic path to expand to multiple menu items. danielebarchiesi@6: $map['admin/structure/types/manage/%node_type'] = array( danielebarchiesi@6: // Link generated items directly to the "Content types" item. danielebarchiesi@6: 'parent' => 'admin/structure/types', danielebarchiesi@6: // Create expansion arguments for the '%node_type' placeholder. danielebarchiesi@6: 'arguments' => array( danielebarchiesi@6: array( danielebarchiesi@6: '%node_type' => array_keys(node_type_get_types()), danielebarchiesi@6: ), danielebarchiesi@6: ), danielebarchiesi@6: ); danielebarchiesi@6: return $map; danielebarchiesi@6: } danielebarchiesi@6: danielebarchiesi@6: /** danielebarchiesi@6: * Add to the administration menu content before it is rendered. danielebarchiesi@6: * danielebarchiesi@6: * Only use this hook to add new data to the menu structure. Use danielebarchiesi@6: * hook_admin_menu_output_alter() to *alter* existing data. danielebarchiesi@6: * danielebarchiesi@6: * @param array $content danielebarchiesi@6: * A structured array suitable for drupal_render(), potentially containing: danielebarchiesi@6: * - menu: The administrative menu of links below the path 'admin/*'. danielebarchiesi@6: * - icon: The icon menu. danielebarchiesi@6: * - account: The user account name and log out link. danielebarchiesi@6: * - users: The user counter. danielebarchiesi@6: * Additionally, these special properties: danielebarchiesi@6: * - #components: The actual components contained in $content are configurable danielebarchiesi@6: * and depend on the 'admin_menu_components' configuration value. #components danielebarchiesi@6: * holds a copy of that for convenience. danielebarchiesi@6: * - #complete: A Boolean indicating whether the complete menu should be built, danielebarchiesi@6: * ignoring the current configuration in #components. danielebarchiesi@6: * Passed by reference. danielebarchiesi@6: * danielebarchiesi@6: * @see hook_admin_menu_output_alter() danielebarchiesi@6: * @see admin_menu_links_menu() danielebarchiesi@6: * @see admin_menu_links_icon() danielebarchiesi@6: * @see admin_menu_links_user() danielebarchiesi@6: * @see theme_admin_menu_links() danielebarchiesi@6: */ danielebarchiesi@6: function hook_admin_menu_output_build(&$content) { danielebarchiesi@6: // In case your implementation provides a configurable component, check danielebarchiesi@6: // whether the component should be displayed: danielebarchiesi@6: if (empty($content['#components']['shortcut.links']) && !$content['#complete']) { danielebarchiesi@6: return; danielebarchiesi@6: } danielebarchiesi@6: danielebarchiesi@6: // Add new top-level item to the menu. danielebarchiesi@6: if (isset($content['menu'])) { danielebarchiesi@6: $content['menu']['myitem'] = array( danielebarchiesi@6: '#title' => t('My item'), danielebarchiesi@6: // #attributes are used for list items (LI). danielebarchiesi@6: '#attributes' => array('class' => array('mymodule-myitem')), danielebarchiesi@6: '#href' => 'mymodule/path', danielebarchiesi@6: // #options are passed to l(). danielebarchiesi@6: '#options' => array( danielebarchiesi@6: 'query' => drupal_get_destination(), danielebarchiesi@6: // Apply a class on the link (anchor). danielebarchiesi@6: 'attributes' => array('class' => array('myitem-link-anchor')), danielebarchiesi@6: ), danielebarchiesi@6: // #weight controls the order of links in the resulting item list. danielebarchiesi@6: '#weight' => 50, danielebarchiesi@6: ); danielebarchiesi@6: } danielebarchiesi@6: // Add link to the icon menu to manually run cron. danielebarchiesi@6: if (isset($content['icon'])) { danielebarchiesi@6: $content['icon']['myitem']['cron'] = array( danielebarchiesi@6: '#title' => t('Run cron'), danielebarchiesi@6: '#access' => user_access('administer site configuration'), danielebarchiesi@6: '#href' => 'admin/reports/status/run-cron', danielebarchiesi@6: ); danielebarchiesi@6: } danielebarchiesi@6: } danielebarchiesi@6: danielebarchiesi@6: /** danielebarchiesi@6: * Change the administration menu content before it is rendered. danielebarchiesi@6: * danielebarchiesi@6: * Only use this hook to alter existing data in the menu structure. Use danielebarchiesi@6: * hook_admin_menu_output_build() to *add* new data. danielebarchiesi@6: * danielebarchiesi@6: * @param array $content danielebarchiesi@6: * A structured array suitable for drupal_render(). Passed by reference. danielebarchiesi@6: * danielebarchiesi@6: * @see hook_admin_menu_output_build() danielebarchiesi@6: */ danielebarchiesi@6: function hook_admin_menu_output_alter(&$content) { danielebarchiesi@6: } danielebarchiesi@6: danielebarchiesi@6: /** danielebarchiesi@6: * Return content to be replace via JS in the cached menu output. danielebarchiesi@6: * danielebarchiesi@6: * @param bool $complete danielebarchiesi@6: * A Boolean indicating whether all available components of the menu will be danielebarchiesi@6: * output and the cache will be skipped. danielebarchiesi@6: * danielebarchiesi@6: * @return array danielebarchiesi@6: * An associative array whose keys are jQuery selectors and whose values are danielebarchiesi@6: * strings containing the replacement content. danielebarchiesi@6: */ danielebarchiesi@6: function hook_admin_menu_replacements($complete) { danielebarchiesi@6: $items = array(); danielebarchiesi@6: // If the complete menu is output, then it is uncached and will contain the danielebarchiesi@6: // current counts already. danielebarchiesi@6: if (!$complete) { danielebarchiesi@6: // Check whether the users count component is enabled. danielebarchiesi@6: $components = variable_get('admin_menu_components', array()); danielebarchiesi@6: if (!empty($components['admin_menu.users']) && ($user_count = admin_menu_get_user_count())) { danielebarchiesi@6: // Replace the counters in the cached menu output with current counts. danielebarchiesi@6: $items['.admin-menu-users a'] = $user_count; danielebarchiesi@6: } danielebarchiesi@6: } danielebarchiesi@6: return $items; danielebarchiesi@6: } danielebarchiesi@6: danielebarchiesi@6: /** danielebarchiesi@6: * Inform about additional module-specific caches that can be cleared. danielebarchiesi@6: * danielebarchiesi@6: * Administration menu uses this hook to gather information about available danielebarchiesi@6: * caches that can be flushed individually. Each returned item forms a separate danielebarchiesi@6: * menu link below the "Flush all caches" link in the icon menu. danielebarchiesi@6: * danielebarchiesi@6: * @return array danielebarchiesi@6: * An associative array whose keys denote internal identifiers for a danielebarchiesi@6: * particular caches (which can be freely defined, but should be in a module's danielebarchiesi@6: * namespace) and whose values are associative arrays containing: danielebarchiesi@6: * - title: The name of the cache, without "cache" suffix. This label is danielebarchiesi@6: * output as link text, but also for the "!title cache cleared." danielebarchiesi@6: * confirmation message after flushing the cache; make sure it works and danielebarchiesi@6: * makes sense to users in both locations. danielebarchiesi@6: * - callback: The name of a function to invoke to flush the individual cache. danielebarchiesi@6: */ danielebarchiesi@6: function hook_admin_menu_cache_info() { danielebarchiesi@6: $caches['update'] = array( danielebarchiesi@6: 'title' => t('Update data'), danielebarchiesi@6: 'callback' => '_update_cache_clear', danielebarchiesi@6: ); danielebarchiesi@6: return $caches; danielebarchiesi@6: }