menu_get_menu

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

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

Версии
5
menu_get_menu()

Return the menu data structure.

The returned structure contains much information that is useful only internally in the menu system. External modules are likely to need only the ['visible'] element of the returned array. All menu items that are accessible to the current user and not hidden will be present here, so modules and themes can use this structure to build their own representations of the menu.

$menu['visible'] will contain an associative array, the keys of which are menu IDs. The values of this array are themselves associative arrays, with the following key-value pairs defined:

  • 'title' - The displayed title of the menu or menu item. It will already have been translated by the locale system.
  • 'description' - The description (link title attribute) of the menu item. It will already have been translated by the locale system.
  • 'path' - The Drupal path to the menu item. A link to a particular item can thus be constructed with l($item['title'], $item['path'], array('title' => $item['description'])).
  • 'children' - A linear list of the menu ID's of this item's children.
Menu ID 0 is the 'root' of the menu. The children of this item are the menus themselves (they will have no associated path). Menu ID 1 will always be one of these children; it is the default 'Navigation' menu.

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

▾ 12 функции вызывают menu_get_menu()

menu_execute_active_handler in includes/menu.inc
Запускает обработчик связанный с активизированным пунктом меню.
menu_get_item in includes/menu.inc
Возвращает пункт меню по заданному $mid, или по $path, если $mid не предоставляется.
menu_get_root_menus in includes/menu.inc
Retrieves the menu ID and title of all root menus.
menu_overview_tree in modules/menu/menu.module
Present the menu tree, rendered along with links to edit menu items.
menu_primary_links in includes/menu.inc
Returns an array containing the primary links. Can optionally descend from the root of the Primary links menu towards the current node for a specified number of levels and return that submenu. Used to generate a primary/secondary menu from different...
menu_rebuild in includes/menu.inc
Заполняет данные, относящееся к меню в базе данных.
menu_set_active_item in includes/menu.inc
Задает путь активного пункта меню.
menu_tree in includes/menu.inc
Возвращает отрендеренное дерево меню.
system_get_module_admin_tasks in modules/system/system.module
_menu_get_active_trail_in_submenu in includes/menu.inc
Find the active trail through a specific subsection of the menu tree.
_menu_item_is_accessible in includes/menu.inc
Determine whether the given menu item is accessible to the current user.
_menu_sort in includes/menu.inc
Comparator routine for use in sorting menu items.

Код

<?php
function menu_get_menu() {
  global $_menu;
  global $user;
  global $locale;

  if (!isset($_menu['items'])) {
    // _menu_build() may indirectly call this function, so prevent infinite loops.
    $_menu['items'] = array();

    $cid = "$user->uid:$locale";
    if ($cached = cache_get($cid, 'cache_menu')) {
      $_menu = unserialize($cached->data);
    }
    else {
      _menu_build();
      // Cache the menu structure for this user, to expire after one day.
      cache_set($cid, 'cache_menu', serialize($_menu), time() + (60 * 60 * 24));
    }

    // Make sure items that cannot be cached are added.
    _menu_append_contextual_items();

    // Reset the cached $menu in menu_get_item().
    menu_get_item(NULL, NULL, TRUE);
  }

  return $_menu;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

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