| 1 |
<?php
|
| 2 |
// $Id: admin_menu.api.php,v 1.2 2009/07/22 20:32:13 sun Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* API documentation for Administration menu.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Alter content in Administration menu bar before it is rendered.
|
| 11 |
*
|
| 12 |
* @param $content
|
| 13 |
* A structured array suitable for drupal_render(), at the very least
|
| 14 |
* containing the keys 'menu' and 'links'. Most implementations likely want
|
| 15 |
* to alter or add to 'links'.
|
| 16 |
*
|
| 17 |
* $content['menu'] contains the HTML representation of the 'admin_menu' menu
|
| 18 |
* tree.
|
| 19 |
* @see admin_menu_menu_alter()
|
| 20 |
*
|
| 21 |
* $content['links'] contains additional top-level links in the Administration
|
| 22 |
* menu, such as the icon menu or the logout link. You can add more items here
|
| 23 |
* or play with the #weight attribute to customize them.
|
| 24 |
* @see theme_admin_menu_links()
|
| 25 |
* @see admin_menu_links_icon()
|
| 26 |
* @see admin_menu_links_user()
|
| 27 |
*/
|
| 28 |
function hook_admin_menu_output_alter(&$content) {
|
| 29 |
// Add new top-level item.
|
| 30 |
$content['links']['myitem'] = array(
|
| 31 |
'#title' => t('My item'),
|
| 32 |
// #attributes are used for list items (LI).
|
| 33 |
'#attributes' => array('class' => array('mymodule-myitem')),
|
| 34 |
'#href' => 'mymodule/path',
|
| 35 |
// #options are passed to l(). Note that you can apply 'attributes' for
|
| 36 |
// links (A) here.
|
| 37 |
'#options' => array(
|
| 38 |
'query' => drupal_get_destination(),
|
| 39 |
),
|
| 40 |
// #weight controls the order of links in the resulting item list.
|
| 41 |
'#weight' => 50,
|
| 42 |
);
|
| 43 |
// Add link to manually run cron.
|
| 44 |
$content['links']['myitem']['cron'] = array(
|
| 45 |
'#title' => t('Run cron'),
|
| 46 |
'#access' => user_access('administer site configuration'),
|
| 47 |
'#href' => 'admin/reports/status/run-cron',
|
| 48 |
);
|
| 49 |
}
|
| 50 |
|