menu_set_active_item
Definition
menu_set_active_item($path = NULL)
includes/menu.inc, line 430
Description
Sets the path of the active menu item.
Related topics
| Name | Description |
|---|---|
| Menu system | Define the navigation menus, and route page requests to code based on URLs. |
Code
<?php
function menu_set_active_item($path = NULL) {
static $stored_mid;
if (!isset($stored_mid) || isset($path)) {
if (!isset($path)) {
$path = $_GET['q'];
}
else {
$_GET['q'] = $path;
}
$menu = menu_get_menu();
while ($path && !isset($menu['path index'][$path])) {
$path = substr($path, 0, strrpos($path, '/'));
}
$stored_mid = isset($menu['path index'][$path]) ? $menu['path index'][$path] : 0;
// Search for default local tasks to activate instead of this item.
$continue = TRUE;
while ($continue) {
$continue = FALSE;
if (isset($menu['items'][$stored_mid]['children'])) {
foreach ($menu['items'][$stored_mid]['children'] as $cid) {
if ($menu['items'][$cid]['type'] & MENU_LINKS_TO_PARENT) {
$stored_mid = $cid;
$continue = TRUE;
}
}
}
}
// Reset the cached $menu in menu_get_item().
menu_get_item(NULL, NULL, TRUE);
}
return $stored_mid;
}
?> 