You are here

function _patterns_menu_parent_options in Patterns 6.2

Same name and namespace in other branches
  1. 6 patterns.module \_patterns_menu_parent_options()

Custom implementation of Drupal's menu_parent_options()

Used to override static caching in menu_tree_all_data() which is preventing menu items created during patterns execution to be included in 'parent item' dropdown and causes validation errors. Hopefully, we can find better solution for this.

1 call to _patterns_menu_parent_options()
patterns_form_alter in ./patterns.module

File

./patterns.module, line 3162
Enables extremely simple adding/removing features to your site with minimal to no configuration

Code

function _patterns_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 = _patterns_menu_tree_all_data($menu_name, NULL);
    $options[$menu_name . ':0'] = '<' . $title . '>';
    _menu_parents_recurse($tree, $menu_name, '--', $options, $item['mlid'], $limit);
  }
  return $options;
}