menu_set_active_item
includes/menu.inc, строка 430
- Версии
- 5
menu_set_active_item($path = NULL)
- 6
menu_set_active_item($path)
Задает путь активного пункта меню.
Связанные темы
Код
<?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;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии