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.

▾ 2 functions call menu_parent_options()

menu_edit_item_form in modules/menu.module
Present the menu item editing form.
menu_parent_options in modules/menu.module
Return a list of menu items that are valid possible parents for the given menu item.

Code

modules/menu.module, line 489

<?php
function menu_parent_options($mid, $pid = 0, $depth = 0) {
  $menu = menu_get_menu();

  $options = array();

  if (isset($menu['items'][$pid]) && $menu['items'][$pid]['children']) {
    usort($menu['items'][$pid]['children'], '_menu_sort');
    foreach ($menu['items'][$pid]['children'] as $child) {
      if ($child != $mid) {
        if ($child > 0 && ($menu['items'][$child]['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_IS_ROOT))) {
          $title = ' '. $menu['items'][$child]['title'];
          for ($i = 0; $i < $depth; $i++) {
            $title = '--'. $title;
          }
          if (!($menu['items'][$child]['type'] & MENU_VISIBLE_IN_TREE)) {
            $title .= ' ('. t('disabled') .')';
          }
          $options[$child] = $title;
        }
        $options += menu_parent_options($mid, $child, $depth + 1);
      }
    }
  }

  return $options;
}
?>
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.