You are here

function menutrails_settings_form in Menu TrailsMenu Trails 6

Same name and namespace in other branches
  1. 5 menutrails.module \menutrails_settings_form()

Form builder function for settings.

This is where menutrails rules are set. The interface here could definitely stand for some improvement. It's especially unhelpful for tagging vocabularies with lots and lots of terms.

1 string reference to 'menutrails_settings_form'
menutrails_menu in ./menutrails.module
Implementation of hook_menu().

File

./menutrails.module, line 191
Menutrails allows the assignment of "trails" which will keep menu items active for individual node views.

Code

function menutrails_settings_form() {
  $options = array(
    '' => '<none>',
  );
  $limit = MENU_MAX_DEPTH - 1;

  // Load up menus.
  foreach (menu_get_menus() as $menu_id => $menu_name) {
    $tree = menu_tree_all_data($menu_id, NULL);
    _menutrails_parents_recurse($tree, $menu_name, '', $options, 0, $limit);
  }
  $form['description'] = array(
    '#type' => 'markup',
    '#weight' => '-10',
    '#value' => t('Use these settings to configure the "menu trails" for your nodes. This determines what menu items are activated when viewing an individual node. For instance, if you have a menu item for "Blog," you may want to have all blog posts fall under that menu.'),
    '#prefix' => '<p>',
    '#suffix' => '</p>',
  );
  $form['menutrails_menu'] = array(
    '#type' => 'select',
    '#weight' => '-6',
    '#options' => menu_get_menus(),
    '#default_value' => variable_get('menutrails_menu', 'primary-links'),
    '#title' => t('Menutrails Menu'),
    '#description' => t('What menu are you most interested in assigning trails to? This menu will be used if there is ambiguity about what menu a node falls under.'),
  );
  $form['menutrails_breadcrumbs'] = array(
    '#type' => 'checkbox',
    '#weight' => '-5',
    '#default_value' => variable_get('menutrails_breadcrumbs', 1),
    '#title' => t('Set breadcrumbs?'),
    '#description' => t('If checked, menutrails will also synchronize the default drupal breadcrumbs with the menu trails, again giving priority to the menu selected above.'),
  );
  $form['order'] = array(
    '#type' => 'markup',
    '#weight' => '-1',
    '#value' => t('Menu trails are evaluated in the order they are shown below.'),
    '#prefix' => '<p>',
    '#suffix' => '</p>',
  );
  $form = array_merge($form, module_invoke_all('menutrails_settings', $options));
  return system_settings_form($form);
}