You are here

function menu_node_import_defaults in Node import 6

Implementation of hook_node_import_defaults().

Global defaults for menus would be confusing. Select only the parent menu.

File

supported/menu.inc, line 44
Support file for the core menu module.

Code

function menu_node_import_defaults($type, $defaults, $fields, $map) {
  $form = array();

  // If we are importing nodes and user can administer menus...
  if (($node_type = node_import_type_is_node($type)) !== FALSE && user_access('administer menu')) {

    // Which main menu will these items be imported under.
    $result = db_query("SELECT * FROM {menu_custom} ORDER BY title");
    $menu_options = array();
    while ($menu = db_fetch_array($result)) {
      $menu_options[$menu['menu_name']] = $menu['menu_name'];
    }
    $menu_options = menu_parent_options(menu_get_menus(), array(
      'mlid' => 0,
    ));
    $form['menu:parent'] = array(
      '#title' => t('Parent Menu'),
      '#type' => 'select',
      '#options' => $menu_options,
      '#default_value' => isset($defaults['menu:parent']) ? $defaults['menu:parent'] : 'primary-links:0',
    );
  }
  return $form;
}