Posted by tars16 on July 17, 2009 at 3:40pm
| Project: | Taxonomy hide |
| Version: | master |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
It would be great if there was an option for or if taxonomy hide could automatically unset the vocabulary from the Advanced Search Form. The option would be better since there could be a situation where you don't want the vocabulary on the node view but would like it in the search form. I've used this code to remove them as I've needed to.
function MODULENAME_form_alter(&$form, $form_state, $form_id){
if ('search_form' == $form_id) {
unset($form['advanced']['category']['#options']['Company Relationship']);
unset($form['advanced']['category']['#options']['Visibility']);
}
return $form;
}Is there a way to incorporate this? Does it make sense to do so?
Comments
#1
Just realized there was another issue for this. Sorry.
#2
1) Where is the other issue? (ok, I've seen it: http://drupal.org/node/204280#comment-2309406)
2) Your code could be added as a patch, isn't it?
#3
This is still a dirty way of doing it but at least it's still more general.
Included at the end of:
taxonomy_hide.module<?php
/**
* Implementation of hook_form_alter()
*/
function taxonomy_hide_form_alter(&$form, $form_state, $form_id){
if ('search_form' == $form_id) {
$voc = taxonomy_get_vocabularies();
$hvoc = variable_get('taxonomy_hide_vocabularies', array());
foreach ($hvoc as $vid)
unset($form['advanced']['category']['#options'][$voc[$vid]->name]);
}
return $form;
}
?>
#4
GTLv97.6 thank you very much, your solution works!
I do not understand why it is necessary to place the module taxonomy_hide but the main thing is that it works ;)
#5
This is great, thank you. I don't understand why this isn't the default behavior.
#6
Subscribing, greetings, Martijn
#7
I've created a patch that adds a new 'Hide on Advanced Search' checkbox to the taxonomy_hide admin settings page. Checking this will implement the above function.