You are here

function _taxonomy_menu_create_options in Taxonomy menu 7

Same name and namespace in other branches
  1. 6.2 taxonomy_menu.module \_taxonomy_menu_create_options()

Creates a form array of taxonomy menu options. Invokes hook_taxonomy_menu_options().

Parameters

$vid: Vocabulary ID.

Return value

array Form array.

1 call to _taxonomy_menu_create_options()
taxonomy_menu_form_alter in ./taxonomy_menu.module
Implements hook_form_alter().

File

./taxonomy_menu.module, line 1071
Adds links to taxonomy terms into a menu.

Code

function _taxonomy_menu_create_options($vid) {
  $options = module_invoke_all('taxonomy_menu_options');

  // Cycle through field.
  foreach ($options as $field_name => $field_elements) {

    // Cycle through each value of the field.
    $variable_name = _taxonomy_menu_build_variable($field_name, $vid);

    // If the variable is set then use that, if the default key is set then use that,
    // otherwise use FALSE.
    $options[$field_name]['#default_value'] = variable_get($variable_name, !empty($options[$field_name]['default']) ? $options[$field_name]['default'] : FALSE);

    // Set the type to checkbox if it is empty.
    if (empty($options[$field_name]['#type'])) {
      $options[$field_name]['#type'] = 'checkbox';
    }

    // Set the options.
    $options['#type'] = 'container';

    // Remove the default value from the array so we don't pass it to the form.
    unset($options[$field_name]['default']);
  }
  return $options;
}