You are here

function custom_breadcrumbs_taxonomy_form_alter in Custom Breadcrumbs 6.2

Implements hook_form_alter().

File

custom_breadcrumbs_taxonomy/custom_breadcrumbs_taxonomy.module, line 298
This module implements taxonomy_based breadcrumbs using a hybrid of methods developed for the custom_breadcrumbs and taxonomy_breadcrumbs modules. Breadcrumbs are provided for node and taxonomy term pages. If 'Use taxonomy hierarchy' is…

Code

function custom_breadcrumbs_taxonomy_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'custom_breadcrumbs_admin_settings') {
    $form['settings']['custom_breadcrumbs_taxonomy'] = array(
      '#type' => 'fieldset',
      '#title' => t('Taxonomy structure'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_use_hierarchy'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use the taxonomy hierarchy to set the breadcrumb trail for nodes and taxonomy pages'),
      '#description' => t('If selected, the custom breadcrumb trail will be constructed from the taxonomy vocabulary and terms associated with the node. Breadcrumb titles will be selected from taxonomy term and vocabulary names.'),
      '#default_value' => variable_get('custom_breadcrumbs_taxonomy_use_hierarchy', TRUE),
      '#weight' => 10,
    );
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_append_breadcrumb'] = array(
      '#type' => 'checkbox',
      '#title' => t('Append taxonomy breadcrumb trail to current breadcrumb for selected node types'),
      '#default_value' => variable_get('custom_breadcrumbs_taxonomy_append_breadcrumb', FALSE),
      '#description' => t('If enabled along with the taxonomy hierarchy option (above), the taxonomy breadcrumb trail will be appended to the current breadcrumb trail.'),
      '#weight' => 20,
    );
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_show_vocabulary'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show vocabulary in breadcrumb trail'),
      '#description' => t('If enabled, the vocabulary name will be shown in the breadcrumb trail, even when a custom breadcrumb has not been defined for the vocabulary. In this case the crumb will not be linked. If a custom breadcrumb has been defined for the vocabulary, it will be displayed whether or not this option is enabled.'),
      '#default_value' => variable_get('custom_breadcrumbs_taxonomy_show_vocabulary', FALSE),
      '#weight' => 25,
    );
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_show_current_term'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show current taxonomy term in breadcrumb trail for node pages'),
      '#description' => t('If enabled, the lightest term associated with node is shown as the last breadcrumb in the breadcrumb trail. Otherwise, the only terms shown in the breadcrumb trail are parent terms (if any parents exist). The recommended setting is enabled.'),
      '#default_value' => variable_get('custom_breadcrumbs_taxonomy_show_current_term', TRUE),
      '#weight' => 30,
    );
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_show_current_term_term'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show current taxonomy term in breadcrumb trail on the taxonomy term page'),
      '#description' => t('If enabled, the taxonomy term name is shown as the last breadcrumb item in the breadcrumb trail on the taxonomy term page.'),
      '#default_value' => variable_get('custom_breadcrumbs_taxonomy_show_current_term_term', FALSE),
      '#weight' => 35,
    );
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_include_node_title'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show current node title in taxonomy breadcrumb trail'),
      '#default_value' => variable_get('custom_breadcrumbs_taxonomy_include_node_title', FALSE),
      '#description' => t("If enabled along with the taxonomy hierarchy option (above) and if viewing a node, the node's title will be shown as the last item in the breadcrumb trail."),
      '#weight' => 40,
    );
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_session'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use session variables to select the most recently viewed taxonomy term to use on pages with more than one term'),
      '#default_value' => variable_get('custom_breadcrumbs_taxonomy_session', FALSE),
      '#description' => t("With this option, the most recently selected term is stored in a session variable and used to prepare the most appropriate taxonomy breadcrumb for pages with multiple terms. If this is not enabled, the lightest term will be used to set the taxonomy breadcrumb on pages with more than one term."),
      '#weight' => 42,
    );
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_no_anon_sessions'] = array(
      '#type' => 'checkbox',
      '#title' => t('Do not use session variables to help select the correct taxonomy term for anonymous users'),
      '#default_value' => variable_get('custom_breadcrumbs_taxonomy_no_anon_sessions', FALSE),
      '#disabled' => !variable_get('custom_breadcrumbs_taxonomy_session', FALSE),
      '#weight' => 44,
    );
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_uncache'] = array(
      '#type' => 'checkbox',
      '#title' => t('Do not cache pages with custom breadcrumbs taxonomy breadcrumbs'),
      '#default_value' => variable_get('custom_breadcrumbs_taxonomy_uncache', FALSE),
      '#disabled' => !variable_get('custom_breadcrumbs_taxonomy_session', FALSE),
      '#description' => t("With normal Drupal caching, dynamic taxonomy breadcrumbs may not be created for anonymous users. Enabling this option will prevent caching of pages that have a taxonomy breadcrumb so the breadcrumb can be properly constructed. This requires the use of session variables and will reduce performance on the pages that are not cached."),
      '#weight' => 46,
    );
    if (module_exists('views')) {
      $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_views'] = array(
        '#type' => 'checkbox',
        '#title' => t('Use taxonomy-based breadcrumbs for views'),
        '#default_value' => variable_get('custom_breadcrumbs_taxonomy_views', FALSE),
        '#description' => t('If enabled, the view argument and/or the taxonomy structure of the nodes returned by views will be used to form the taxonomy breadcrumb trail.'),
        '#weight' => 50,
      );
      $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_result_nodes'] = array(
        '#type' => 'checkbox',
        '#title' => t('Use the taxonomy of nodes returned by a view to create the taxonomy breadcrumb'),
        '#default_value' => variable_get('custom_breadcrumbs_taxonomy_result_nodes', FALSE),
        '#description' => t('If enabled, when a taxonomy-based view argument is not available the taxonomy from the first node returned by the view will be used. The view results will not be used if the taxonomy can be determined from the view argument.'),
        '#weight' => 55,
      );
    }
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_include_nodes'] = array(
      '#type' => 'radios',
      '#title' => t('Include or exclude taxonomy-based breadcrumbs for the following node types'),
      '#default_value' => variable_get('custom_breadcrumbs_taxonomy_include_nodes', 0),
      '#options' => array(
        1 => t('Include'),
        0 => t('Exclude'),
      ),
      '#weight' => 60,
    );
    $cb_tax_types = (array) variable_get('custom_breadcrumbs_taxonomy_node_types', CUSTOM_BREADCRUMBS_TAXONOMY_NODE_TYPES_DEFAULT);
    $default = array();
    foreach ($cb_tax_types as $index => $value) {
      if ($value) {
        $default[] = $index;
      }
    }
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_node_types'] = array(
      '#type' => 'checkboxes',
      '#multiple' => TRUE,
      '#title' => t('Node types to include or exclude'),
      '#default_value' => $default,
      '#options' => array_map('check_plain', node_get_types('names')),
      '#description' => t('A list of node types to include or exclude applying taxonomy-based breadcrumbs.'),
      '#weight' => 70,
    );
    $vocabs = taxonomy_get_vocabularies();
    $options = array();
    foreach ($vocabs as $vocab) {
      $name = check_plain($vocab->name);
      $options[$vocab->vid] = $name;
    }
    $cb_vocabs = variable_get('custom_breadcrumbs_taxonomy_excluded_vocabs', array());
    $default = array();
    foreach ($cb_vocabs as $index => $value) {
      if ($value) {
        $default[] = $index;
      }
    }
    $form['settings']['custom_breadcrumbs_taxonomy']['custom_breadcrumbs_taxonomy_excluded_vocabs'] = array(
      '#type' => 'checkboxes',
      '#multiple' => TRUE,
      '#title' => t('Vocabularies to exclude from custom breadcrumbs taxonomy'),
      '#default_value' => $default,
      '#options' => $options,
      '#description' => t('A list of vocabularies to exclude applying taxonomy-based breadcrumbs.'),
      '#weight' => 75,
    );
  }
}