hook_admin_menu_output_alter

Versions
6 – 7
hook_admin_menu_output_alter(&$content)

Alter content in Administration menu bar before it is rendered.

$content['menu'] contains the HTML representation of the 'admin_menu' menu tree.

See also

admin_menu_menu_alter()

$content['links'] contains additional top-level links in the Administration menu, such as the icon menu or the logout link. You can add more items here or play with the #weight attribute to customize them.

See also

theme_admin_menu_links()

@see admin_menu_links_icon()

See also

admin_menu_links_user()

Parameters

$content A structured array suitable for drupal_render(), at the very least containing the keys 'menu' and 'links'. Most implementations likely want to alter or add to 'links'.

Code

contributions/admin_menu/admin_menu.api.php, line 27

<?php
function hook_admin_menu_output_alter(&$content) {
  // Add new top-level item.
  $content['links']['myitem'] = array(
    '#title' => t('My item'),
    // #attributes are used for list items (LI). Note the special syntax for
    // the 'class' attribute.
    '#attributes' => array('class' => array('mymodule-myitem')),
    '#href' => 'mymodule/path',
    // #options are passed to l(). Note that you can apply 'attributes' for
    // links (A) here.
    '#options' => array(
      'query' => drupal_get_destination(),
    ),
    // #weight controls the order of links in the resulting item list.
    '#weight' => 50,
  );
  // Add link to manually run cron.
  $content['links']['myitem']['cron'] = array(
    '#title' => t('Run cron'),
    '#access' => user_access('administer site configuration'),
    '#href' => 'admin/reports/status/run-cron',
  );
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters (without spaces) shown in the image.