function menu_set_active_menu_names

Sets (or gets) the active menu for the current page.

The active menu for the page determines the active trail.

Return value

An array of menu machine names, in order of preference. The 'system.menu.active_menus_default' config item may be used to assert a menu order different from the order of creation, or to prevent a particular menu from being used at all in the active trail. E.g., $conf['system.menu']['active_menus_default'] = array('tools', 'main').

Related topics

2 calls to menu_set_active_menu_names()
book_page_alter in drupal/core/modules/book/book.module
Implements hook_page_alter().
menu_get_active_menu_names in drupal/core/includes/menu.inc
Gets the active menu for the current page.

File

drupal/core/includes/menu.inc, line 2272
API for the Drupal menu system.

Code

function menu_set_active_menu_names($menu_names = NULL) {
  $active =& drupal_static(__FUNCTION__);
  if (isset($menu_names) && is_array($menu_names)) {
    $active = $menu_names;
  }
  elseif (!isset($active)) {
    $config = config('system.menu');
    $active = $config
      ->get('active_menus_default') ?: array_keys(menu_list_system_menus());
  }
  return $active;
}