Experimental project
This is a sandbox project, which contains experimental code for developer use only.
Update
===============================================
This module is now part of Taxonomy Tools.
===============================================
This module allows you to limit the taxonomy terms listed in a term reference form element or in a views exposed filter.
Description
Based on a status field disabled terms will be removed from the options by a hook_field_widget_form_alter() implementation for term reference field widgets and by a hook_form_FORM_ID_alter() for views exposed forms.
The module allows you to enable/disable this limitation with permissions for each vocabulary.
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 and checkbox/radio widgets for term reference fields.
There is ongoing development to support autocomplete widgets as well.
How to use
- download the module and place it under 'sites/all/modules/contrib' folder
- with Drush use: drush dl taxonomy_publisher_filter
- enable the module from the modules page: 'admin/build/modules'
- 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,
);
}
Project information
Unsupported
Not supported (i.e. abandoned), and no longer being developed. Learn more about dealing with unsupported (abandoned) projectsObsolete
Use of this project is deprecated.- Created by balintcsaba on , updated
