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