function menu_set_active_trail

×

Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
cis7 menu.inc menu_set_active_trail($new_trail = NULL)
cle7 menu.inc menu_set_active_trail($new_trail = NULL)
elmsmedia7 menu.inc menu_set_active_trail($new_trail = NULL)
icor7 menu.inc menu_set_active_trail($new_trail = NULL)
meedjum_blog7 menu.inc menu_set_active_trail($new_trail = NULL)
mooc7 menu.inc menu_set_active_trail($new_trail = NULL)

Sets the active trail (path to the menu tree root) of the current page.

Any trail set by this function will only be used for functionality that calls menu_get_active_trail(). Drupal core only uses trails set here for breadcrumbs and the page title and not for menu trees or page content. Additionally, breadcrumbs set by drupal_set_breadcrumb() will override any trail set here.

To affect the trail used by menu trees, use menu_tree_set_path(). To affect the page content, use menu_set_active_item() instead.

Parameters

$new_trail: Menu trail to set; the value is saved in a static variable and can be retrieved by menu_get_active_trail(). The format of this array should be the same as the return value of menu_get_active_trail().

Return value

The active trail. See menu_get_active_trail() for details.

Related topics

2 calls to menu_set_active_trail()
menu_get_active_trail in includes/menu.inc
Gets the active trail (path to root menu root) of the current page.
menu_position_activate_rule in sites/all/modules/local_contrib/menu_position/menu_position.module
Evaluates all rules based on the given path.
2 string references to 'menu_set_active_trail'
context_reaction_menu::menu_navigation_links in sites/all/modules/ulmus/context/plugins/context_reaction_menu.inc
Wrapper around menu_navigation_links() that gives themers the option of building navigation links based on an active context trail.
menu_set_active_item in includes/menu.inc
Sets the active path, which determines which page is loaded.

File

includes/menu.inc, line 2367
API for the Drupal menu system.

Code

function menu_set_active_trail($new_trail = NULL) {
  $trail = &drupal_static(__FUNCTION__);

  if (isset($new_trail)) {
    $trail = $new_trail;
  }
  elseif (!isset($trail)) {
    $trail = array();
    $trail[] = array(
      'title' => t('Home'),
      'href' => '<front>',
      'link_path' => '',
      'localized_options' => array(),
      'type' => 0,
    );

    // Try to retrieve a menu link corresponding to the current path. If more
    // than one exists, the link from the most preferred menu is returned.
    $preferred_link = menu_link_get_preferred();
    $current_item = menu_get_item();

    // There is a link for the current path.
    if ($preferred_link) {
      // Pass TRUE for $only_active_trail to make menu_tree_page_data() build
      // a stripped down menu tree containing the active trail only, in case
      // the given menu has not been built in this request yet.
      $tree = menu_tree_page_data($preferred_link['menu_name'], NULL, TRUE);
      list($key, $curr) = each($tree);
    }
    // There is no link for the current path.
    else {
      $preferred_link = $current_item;
      $curr = FALSE;
    }

    while ($curr) {
      $link = $curr['link'];
      if ($link['in_active_trail']) {
        // Add the link to the trail, unless it links to its parent.
        if (!($link['type'] & MENU_LINKS_TO_PARENT)) {
          // The menu tree for the active trail may contain additional links
          // that have not been translated yet, since they contain dynamic
          // argument placeholders (%). Such links are not contained in regular
          // menu trees, and have only been loaded for the additional
          // translation that happens here, so as to be able to display them in
          // the breadcumb for the current page.
          // @see _menu_tree_check_access()
          // @see _menu_link_translate()
          if (strpos($link['href'], '%') !== FALSE) {
            _menu_link_translate($link, TRUE);
          }
          if ($link['access']) {
            $trail[] = $link;
          }
        }
        $tree = $curr['below'] ? $curr['below'] : array();
      }
      list($key, $curr) = each($tree);
    }
    // Make sure the current page is in the trail to build the page title, by
    // appending either the preferred link or the menu router item for the
    // current page. Exclude it if we are on the front page.
    $last = end($trail);
    if ($preferred_link && $last['href'] != $preferred_link['href'] && !drupal_is_front_page()) {
      $trail[] = $preferred_link;
    }
  }
  return $trail;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.