function taxonomy_menu_form_taxonomy_form_vocabulary in Taxonomy menu 8
Same name and namespace in other branches
- 7.2 taxonomy_menu.admin.inc \taxonomy_menu_form_taxonomy_form_vocabulary()
Form constructor for the vocabulary editing form. We add our taxonomy_menu settings in here on a per-vocabulary basis.
See also
1 call to taxonomy_menu_form_taxonomy_form_vocabulary()
File
- ./
taxonomy_menu.admin.inc, line 14 - Administrative page callbacks for the Taxonomy menu module.
Code
function taxonomy_menu_form_taxonomy_form_vocabulary(&$form, &$form_state) {
// Do not alter on deletion.
if (isset($form_state['confirm_delete']) && isset($form_state['values']['vid'])) {
return;
}
// Build options.
$defaults = taxonomy_menu_taxonomy_menu_vocabulary_settings();
$form['taxonomy_menu'] = array(
'#type' => 'details',
'#title' => t('Taxonomy menu'),
'#weight' => 10,
'#tree' => TRUE,
);
// Get the vocabulary ID.
$vid = $form_state['controller']
->getEntity()->vid ?: 0;
// Turn the vocab terms into menu items and add an option at the top for
// disabling the menu.
$menu_link = entity_create('menu_link', array(
'mlid' => 0,
));
$menu_items = menu_ui_parent_options(menu_ui_get_menus(), $menu_link);
array_unshift($menu_items, t('- Not selected -'));
// Try to get the current menu location value if the vocabulary has already
// been created.
if ($vid) {
$menu_name = taxonomy_menu_variable_get('vocab_menu', $vid, 0);
$mlid = taxonomy_menu_variable_get('vocab_parent', $vid, 0);
$current_menu_value = $menu_name . ':' . $mlid;
$default_menu = isset($menu_items[$current_menu_value]) ? $current_menu_value : 0;
}
else {
$default_menu = 0;
}
// Menu location.
$form['taxonomy_menu']['vocab_parent'] = array(
'#type' => 'select',
'#title' => t('Menu location'),
'#default_value' => $default_menu,
'#options' => $menu_items,
'#description' => t('The menu and parent under which to insert taxonomy menu items.'),
'#attributes' => array(
'class' => array(
'menu-title-select',
),
),
);
// Path.
$form['taxonomy_menu']['path'] = array(
'#type' => 'select',
'#title' => t('Menu path type'),
'#description' => t('<b>Warning:</b> Multi-terms path is not available in Drupal by default, which means that you will have to register it using a module like Views for example.'),
'#default_value' => taxonomy_menu_variable_get('path', $vid, 0),
'#options' => taxonomy_menu_get_paths(),
);
// Sync
$variable_name = _taxonomy_menu_build_variable('sync', $vid);
$form['taxonomy_menu']['sync'] = array(
'#type' => 'checkbox',
'#title' => t('Synchronise changes to this vocabulary'),
'#description' => t('Every time a term is added/deleted/modified, the corresponding menu link will be altered too.'),
'#default_value' => taxonomy_menu_variable_get('sync', $vid, $defaults['sync']),
);
// Rebuild
$variable_name = _taxonomy_menu_build_variable('rebuild', $vid);
$form['taxonomy_menu']['rebuild'] = array(
'#type' => 'checkbox',
'#title' => t('Rebuild the menu on submit.'),
'#description' => t('<strong>Warning</strong>: This will delete then re-create all of the menu items. Only use this option if you are experiencing issues like missing menu items or other inconsistencies.'),
'#default_value' => taxonomy_menu_variable_get('rebuild', $vid, $defaults['rebuild']),
);
// Path options.
$form['taxonomy_menu']['options_paths'] = array(
'#type' => 'details',
'#title' => t('Path options'),
'#collapsed' => TRUE,
);
/*$form['taxonomy_menu']['options_paths']['display_descendants'] = array(
'#type' => 'checkbox',
'#title' => t('Display descendants'),
'#description' => t('Path will be changed to taxonomy/term/tid+tid+tid... for all terms that have child terms.'),
'#default_value' => taxonomy_menu_variable_get('display_descendants', $vid, $defaults['display_descendants']),
);*/
$form['taxonomy_menu']['options_paths']['end_all'] = array(
'#type' => 'checkbox',
'#title' => t("Use 'all' at the end of URL"),
'#description' => t('This changes tid+tid+tid to "All" in term when <em>Display descendants</em> has been selected.<br />Only used if <em>Menu path type</em> is "Default path".<br />Works with default taxonomy page.'),
'#default_value' => taxonomy_menu_variable_get('end_all', $vid, $defaults['end_all']),
'#disabled' => TRUE,
);
// Other options.
$form['taxonomy_menu']['options_structure'] = array(
'#type' => 'details',
'#title' => t('Structure options'),
'#collapsed' => TRUE,
);
$form['taxonomy_menu']['options_structure']['expanded'] = array(
'#type' => 'checkbox',
'#title' => t('Auto expand menu items'),
'#description' => t('Automatically show all menu items as expanded.'),
'#default_value' => taxonomy_menu_variable_get('expanded', $vid, $defaults['expanded']),
);
$form['taxonomy_menu']['options_structure']['hide_empty_terms'] = array(
'#type' => 'checkbox',
'#title' => t('Hide empty terms'),
'#description' => t('Hide terms with no items attached to them. This is not recursive by default.'),
'#default_value' => taxonomy_menu_variable_get('hide_empty_terms', $vid, $defaults['hide_empty_terms']),
);
$form['taxonomy_menu']['options_structure']['flat'] = array(
'#type' => 'checkbox',
'#title' => t('Flatten the taxonomy\'s hierarchy in the menu'),
'#description' => t('Add all menu items to the same level rather than hierarchically.'),
'#default_value' => taxonomy_menu_variable_get('flat', $vid, $defaults['flat']),
);
// Markup options.
$form['taxonomy_menu']['options_markup'] = array(
'#type' => 'details',
'#title' => t('Markup options'),
'#collapsed' => TRUE,
);
$form['taxonomy_menu']['options_markup']['display_title_attr'] = array(
'#type' => 'checkbox',
'#title' => t('Display HTML title attributes on menu links.'),
'#description' => t('Extra information, like the description of the term, is shown as a tooltip text when the mouse moves over the menu link.'),
'#default_value' => taxonomy_menu_variable_get('display_title_attr', $vid, $defaults['display_title_attr']),
);
$form['taxonomy_menu']['options_markup']['term_item_description'] = array(
'#type' => 'checkbox',
'#title' => t('HTML title: Use description of the taxonomy term.'),
'#description' => t('Title will default to empty if the description of the term is not used.'),
'#default_value' => taxonomy_menu_variable_get('term_item_description', $vid, $defaults['term_item_description']),
'#states' => array(
'visible' => array(
':input[name="taxonomy_menu[options_markup][display_title_attr]"]' => array(
'checked' => TRUE,
),
),
),
);
$form['taxonomy_menu']['options_markup']['display_num'] = array(
'#type' => 'checkbox',
'#title' => t('Display the count of nodes referencing a term in the menu link title.'),
'#description' => t('Number of nodes is calculated the Drupal Core way. This is not recursive by default.'),
'#default_value' => taxonomy_menu_variable_get('display_num', $vid, $defaults['display_num']),
);
/*$form['taxonomy_menu']['options_markup']['voc_item_description'] = array(
'#type' => 'checkbox',
'#title' => t('Add description for vocabulary'),
'#description' => t('Add the vocabulary description to the vocabulary menu item.'),
'#default_value' => taxonomy_menu_variable_get('voc_item_description', $vid, $defaults['voc_item_description']),
);*/
// Add an extra submit handler to save these settings.
$form['actions']['submit']['#submit'][] = 'taxonomy_menu_vocab_submit';
}