Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, everybody.
I was working with the Webform module with special software requirements:
- Get published taxonomy terms in a select.
- Avoid using module development from zero.
So I used 2 more modules:
- Webform Term Options: To get a set of taxonomy temrs and
- Taxonomy Tools: to get taxonomy terms filtered by Taxonomy Publisher Filter submodule activation.
But, when I retrieve taxonomy terms on a select in webform I got published and unpublished terms.
Solving this problem was pretty simple, I just modified /sites/all/modules/webform_term_opts/webform_term_opts.module and remplaced webform_term_options_vocabulary_terms
function as follows:
function webform_term_options_vocabulary_terms($component, $flat, $vid) {
$terms = array();
//previous version without using filters
//$tree = taxonomy_get_tree($vid);
/**
* @todo Do something for hierarchical vocabularies here (hint: use $flat arg)
*/
/*foreach ($tree as $term) {
$terms['tid_' . $term->tid] = $term->name;
}*/
//Actual version using taxonomy terms filter module from taxonomy tools
$tree = _taxonomy_publisher_filter_custom_form($vid);
foreach ($tree as $key => $value) {
$terms['tid_' . $key] = $value;
}
return $terms;
}
Following https://www.drupal.org/node/1895610 community documentation.
Hope it help y'all.
Bye.
Comments
Comment #2
JoAMoS CreditAttribution: JoAMoS as a volunteer commentedMinor Correction: Changed Link name from (wrong) Webform Tools to (correct) Taxonomy Tools.