function admin_menu_menu_alter in Administration menu 6.3
Same name and namespace in other branches
- 8.3 admin_menu.module \admin_menu_menu_alter()
- 6 admin_menu.module \admin_menu_menu_alter()
- 7.3 admin_menu.module \admin_menu_menu_alter()
Implements hook_menu_alter().
File
- ./
admin_menu.module, line 90 - Render an administrative menu as a dropdown menu at the top of the window.
Code
function admin_menu_menu_alter(&$items) {
foreach ($items as $path => $item) {
if (!strncmp($path, 'admin/', 6)) {
if (isset($item['type'])) {
// For any reason, content-type menu items are registered individually
// in Drupal core, but also by CCK. We a) have to copy and re-assign
// them the proper router path and b) turn their parent items from
// MENU_CALLBACK into something visible; otherwise, the menu system
// does not find the parents and relocates child items to the top-level.
if (strpos($path, 'admin/content/node-type/') === 0) {
// Copy item with fixed router path.
$newpath = str_replace('/node-type/', '/types/', $path);
$items[$newpath] = $item;
// Use new item from here, but leave old intact to play nice with
// others.
$path = $newpath;
// Turn MENU_CALLBACK items into visible menu items.
if ($item['type'] == MENU_CALLBACK) {
$items[$path]['type'] = MENU_NORMAL_ITEM;
}
}
// Skip invisible MENU_CALLBACKs.
if ($item['type'] == MENU_CALLBACK) {
continue;
}
// Trick local tasks and actions into the visible menu tree.
if ($item['type'] & MENU_IS_LOCAL_TASK) {
$items[$path]['_visible'] = TRUE;
}
$items[$path]['menu_name'] = 'admin_menu';
}
}
}
// Remove 'admin', so children appear on the top-level.
$items['admin']['menu_name'] = 'admin_menu';
// Remove local tasks on 'admin'.
$items['admin/by-task']['_visible'] = FALSE;
$items['admin/by-module']['_visible'] = FALSE;
// menu_link_save() looks up the parent's menu_name directly in the database
// instead of taking data in hook_menu() into account. When installing
// admin_menu, {menu_links} contains the default value of 'navigation', which
// is thereby applied to all items, even if this function altered them. There
// is no other way to override this behavior.
// Additionally, if links below admin/ were moved or customized in any way and
// those are moved back into the administration menu, then the menu system
// will not calculate/assign the proper menu link parents when the parent item
// (here: 'admin') is marked as customized.
db_query("UPDATE {menu_links} SET menu_name = 'admin_menu', customized = 0 WHERE router_path = 'admin'");
// Flush client-side caches whenever the menu is rebuilt.
admin_menu_flush_caches();
}