On this page
Taxonomy Publisher Filter
Dependencies
It depends on the Taxonomy Publisher module (now part of the Taxonomy tools project), which
attaches a status field to the taxonomy terms of the vocabularies you select.
Versions
The current version supports select, checkbox/radio and autocomplete widgets for term reference fields.
How to use
- download the module and place it under 'sites/all/modules/contrib' folder
- with Drush use: drush dl taxonomy_tools
- enable the module from the modules page: 'admin/build/modules' the Taxonomy Publisher & Taxonomy Publisher Filter module
- enable taxonomy publisher on the vocabularies you wish to limit
- enable/disable the terms in the above vocabularies
- configure roles that show see the limited list only under admin/people/permission
Custom Form
_taxonomy_publisher_filter_custom_form($vid, $settings) function is helpful to filter your select or checkbox/radio field in custom forms.
The function will expect a vocabulary id by default and will return the filtered option list.
$option = _taxonomy_publisher_filter_custom_form($vid);
Also is having an optional array parameter where you can sett to cache the result (very useful with big vocabulary) and to use the module permission settings for the vocabulary you filter.
$settings = array();
$settings['by_role'] = TRUE;
$settings['cache'] = $form_id;
$option = _taxonomy_publisher_filter_custom_form($vid,$settings);
If the $settings['by_role'] is not sett or is FALSE will filter the vocabulary for all roles.
Even if is optional is indicated to use the cache feature and if you do so to avoid cache conflict use the form ID to his value.
Exemple:
function hook_form_alter(&$form, &$form_state, $form_id) {
$settings = array();
$settings['by_role'] = TRUE;
$settings['cache'] = $form_id;
$options = _taxonomy_publisher_filter_custom_form($vid, $settings);
$form['my_options_1'] = array(
'#type' => 'select',
'#title' => t('My List'),
'#options' => $options,
);
}
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion