menu_set_active_item

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/menu.inc, строка 430

Версии
5
menu_set_active_item($path = NULL)
6
menu_set_active_item($path)

Задает путь активного пункта меню.

Связанные темы

▾ 4 функции вызывают menu_set_active_item()

drupal_access_denied in includes/common.inc
Генерирует ошибку 403 если для просмотра страницы недостаточно прав.
drupal_not_found in includes/common.inc
Генерирует ошибку 404 (страница не найдена) если запрос не удалось обработать.
menu_get_active_item in includes/menu.inc
Возвращает ID активного пункта меню.
menu_set_location in includes/menu.inc
Change the current menu location of the user.

Код

<?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;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему