menu_parent_options

Versions
4.6 – 5
menu_parent_options($mid, $pid = 0, $depth = 0)
6 – 7
menu_parent_options($menus, $item)

Return a list of menu items that are valid possible parents for the given menu item.

@todo This has to be turned into a #process form element callback. The 'menu_override_parent_selector' variable is entirely superfluous.

Parameters

$menus An array of menu names and titles, such as from menu_get_menus().

$item The menu item or the node type for which to generate a list of parents. If $item['mlid'] == 0 then the complete tree is returned.

Return value

An array of menu link titles keyed on the a string containing the menu name and mlid. The list excludes the given item and its children.

▾ 3 functions call menu_parent_options()

menu_edit_item in modules/menu/menu.admin.inc
Menu callback; Build the menu link editing form.
menu_form_alter in modules/menu/menu.module
Implements hook_form_alter(). Adds menu item fields to the node form.
menu_form_node_type_form_alter in modules/menu/menu.module
Implements hook_form_FORM_ID_alter() for the node type form. Adds menu options to the node type form.

Code

modules/menu/menu.module, line 312

<?php
function menu_parent_options($menus, $item) {
  // The menu_links table can be practically any size and we need a way to
  // allow contrib modules to provide more scalable pattern choosers.
  // hook_form_alter is too late in itself because all the possible parents are
  // retrieved here, unless menu_override_parent_selector is set to TRUE.
  if (variable_get('menu_override_parent_selector', FALSE)) {
    return array();
  }

  $available_menus = array();
  if (is_array($item)) {
    // If $item is an array fill it with all menus given to this function.
    $available_menus = $menus;
  }
  else {
    // If $item is a node type, get all available menus for this type and
    // prepare a dummy menu item for _menu_parent_depth_limit().
    $type_menus = variable_get('menu_options_' . $item, array('main-menu' => 'main-menu'));
    foreach ($type_menus as $menu) {
      $available_menus[$menu] = $menu;
    }
    $item = array('mlid' => 0);
  }

  return _menu_get_options($menus, $available_menus, $item);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.