menu_navigation_links

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

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

Версии
6
menu_navigation_links($menu_name, $level = 0)

Возращает массив ссылок для меню навигации.

Параметры

$menu_name Имя этого меню.

$level Дополнительно, глубина возвращенного меню.

Возвращаемое значение

Массив ссылок, определяющий меню и уровни.

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

▾ 2 функции вызывают menu_navigation_links()

menu_primary_links in includes/menu.inc
Возвращает массив ссылок для отображения меню «Основные ссылки».
menu_secondary_links in includes/menu.inc
Возвращает массив ссылок, которые должны отображаться как Дополнительные ссылки.

Код

<?php
function menu_navigation_links($menu_name, $level = 0) {
  // Don't even bother querying the menu table if no menu is specified.
  if (empty($menu_name)) {
    return array();
  }

  // Get the menu hierarchy for the current page.
  $tree = menu_tree_page_data($menu_name);

  // Go down the active trail until the right level is reached.
  while ($level-- > 0 && $tree) {
    // Loop through the current level's items until we find one that is in trail.
    while ($item = array_shift($tree)) {
      if ($item['link']['in_active_trail']) {
        // If the item is in the active trail, we continue in the subtree.
        $tree = empty($item['below']) ? array() : $item['below'];
        break;
      }
    }
  }

  // Create a single level of links.
  $links = array();
  foreach ($tree as $item) {
    if (!$item['link']['hidden']) {
      $class = '';
      $l = $item['link']['localized_options'];
      $l['href'] = $item['link']['href'];
      $l['title'] = $item['link']['title'];
      if ($item['link']['in_active_trail']) {
        $class = ' active-trail';
      }
      // Keyed with the unique mlid to generate classes in theme_links().
      $links['menu-'. $item['link']['mlid'] . $class] = $l;
    }
  }
  return $links;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

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