1 menu.module | menu_parent_options($menus, $item, $type = '') |
Return a list of menu items that are valid possible parents for the given menu item.
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.
$type: The node type for which to generate a list of parents. If $item itself is a node type then $type is ignored.
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.
File
- core/
modules/ menu/ menu.module, line 355 - Allows administrators to customize the site's menus.
Code
function menu_parent_options($menus, $item, $type = '') {
$available_menus = array();
if (!is_array($item)) {
// If $item is not an array then it is a node type.
// Use it as $type and prepare a dummy menu item for _menu_get_options().
$type = $item;
$item = array('mlid' => 0);
}
if (empty($type)) {
// If no node type is set, use all menus given to this function.
$available_menus = $menus;
}
else {
// If a node type is set, use all available menus for this type.
$node_type = node_type_load($type);
foreach ($node_type->settings['menu_options'] as $menu) {
$available_menus[$menu] = $menu;
}
}
return _menu_get_options($menus, $available_menus, $item);
}