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?

CommentFileSizeAuthor
#7 hide_advanced_search-522562-7.patch2.18 KBgrasmash

Comments

tars16’s picture

Just realized there was another issue for this. Sorry.

calbasi’s picture

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?

GTLv97.6’s picture

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


/**
 * 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;
}

Clément’s picture

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 ;)

ktf’s picture

This is great, thank you. I don't understand why this isn't the default behavior.

summit’s picture

Subscribing, greetings, Martijn

grasmash’s picture

StatusFileSize
new2.18 KB

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.