_menu_get_active_trail_in_submenu

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

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

Версии
5
_menu_get_active_trail_in_submenu($pid)

Find the active trail through a specific subsection of the menu tree.

Параметры

$pid The root item from which the active trail must descend.

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

menu_in_active_trail_in_submenu in includes/menu.inc
Returns TRUE when the menu item is in the active trail within a specific subsection of the menu tree.
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...

Код

<?php
function _menu_get_active_trail_in_submenu($pid) {
  static $trails;

  if (!isset($trails)) {
    // Find all menu items which point to the current node and for each
    // follow the parents up the chain to build an active trail.
    $trails = array();
    $menu = menu_get_menu();
    $path = $_GET['q'];
    $count = 0;
    while ($path && !$count) {
      foreach ($menu['items'] as $key => $item) {
        if (isset($item['path']) && ($item['path'] == $path || ($item['path'] == '<front>' && drupal_is_front_page()))) {
          $trails[$count] = array();
          $mid = $key;
          while ($mid && $menu['items'][$mid]) {
            array_unshift($trails[$count], $mid);
            $mid = $menu['items'][$mid]['pid'];
          }
          $count ++;
        }
      }
      $path = substr($path, 0, strrpos($path, '/'));
    }
  }

  if ($trails) {
    foreach ($trails as $trail) {
      $count_trail = count($trail);
      for ($i = 0; $i < $count_trail; $i++) {
        if ($trail[$i] == $pid) {
          // Return a trail from $pid down to the current page inclusive.
          for ( ; $i < $count_trail; $i++) {
            $subtrail[] = $trail[$i];
          }
          return $subtrail;
        }
      }
    }
  }

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

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