menu_parent_options

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 – drupal7 menu_parent_options($menus, $item)

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

Übergabeparameter

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

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

Rückgabewert

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.

▾ 2 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
Implementation of hook_form_alter(). Adds menu item fields to the node form.

Code

modules/menu/menu.module, line 209

<?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();
  }
  // If the item has children, there is an added limit to the depth of valid parents.
  if (isset($item['parent_depth_limit'])) {
    $limit = $item['parent_depth_limit'];
  }
  else {
    $limit = _menu_parent_depth_limit($item);
  }

  foreach ($menus as $menu_name => $title) {
    $tree = menu_tree_all_data($menu_name, NULL);
    $options[$menu_name . ':0'] = '<' . $title . '>';
    _menu_parents_recurse($tree, $menu_name, '--', $options, $item['mlid'], $limit);
  }
  return $options;
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen