function taxonomy_menu_custom_paths_form_taxonomy_form_vocabulary_alter in Taxonomy menu 7.2
Implements hook_form_FORM_ID_alter().
Adds Taxonomy menu custom path settings on a per-vocabulary basis.
See also
taxonomy_menu_custom_paths_vocabulary_validate()
File
- taxonomy_menu_custom_paths/
taxonomy_menu_custom_paths.module, line 26 - taxonomy_menu_custom_paths module
Code
function taxonomy_menu_custom_paths_form_taxonomy_form_vocabulary_alter(&$form, &$form_state) {
$vid = isset($form['vid']) && $form['vid']['#value'] ? $form['vid']['#value'] : 0;
$form['taxonomy_menu']['options_custom_path'] = array(
'#type' => 'fieldset',
'#title' => t('Custom path options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t("<strong>Warning:</strong> These settings uses custom paths that are not registered in Drupal by default. You need to register them <strong>before</strong> you create the taxonomy menu. For example, you could use a view in order to do that."),
'#states' => array(
'visible' => array(
':input[name="taxonomy_menu[path]"]' => array(
'value' => 'taxonomy_menu_path_custom',
),
),
),
);
$form['taxonomy_menu']['options_custom_path']['custom_path_base'] = array(
'#title' => t('Base path'),
'#weight' => 0,
'#type' => 'textfield',
'#default_value' => taxonomy_menu_variable_get('custom_path_base', $vid, ''),
'#description' => t("Path 'base_path/%' must be available, where the argument is a Term ID (tid)."),
);
$form['taxonomy_menu']['options_custom_path']['custom_path_depth'] = array(
'#title' => t('Depth modifier'),
'#weight' => 1,
'#description' => t("Path 'base_path/%/%' must be available, where the arguments are respectively a Term ID (tid) and a Depth Modifier."),
'#default_value' => taxonomy_menu_variable_get('custom_path_depth', $vid, ''),
'#type' => 'textfield',
);
// Add a custom validation function.
array_unshift($form['#validate'], 'taxonomy_menu_custom_paths_vocabulary_validate');
}