I am looking for a way to have an exposed filter in a view, based on the option "has taxonomy terms with depth", that can look for a term in a positive and a negative depth.

An example : I want that when "EUROPE" is selected, all contents that have "WORLD" or "SPAIN" "ENGLAND" Show-up in the results.

Does anyone has an idea ?

Thank you in advance.


I've done stuff like this (eg, World and nesting of regions in the world with heirarchical taxonomies).

Take a look at Taxonomy Edge. It provides view integrations to provide search filters for "Taxonomy edge: Parent term ID" and I believe "Taxonomy edge: Parent term has child term". I mean it adds some useful parent and child Views search filters (I dont believe it adds a single positive or negative search as you've described).

| improve this answer | |

I think i found a way to do it. One should create both type of filters (with positive and negative depth), and then implements a hook_form_alter this way :

function example_form_alter(&$form, &$form_state, $form_id){

//forbid the direct access to the filter you want to hide
$form['term_node_tid_depth_negative']['#access'] = FALSE;
//put the value of one filter in the other.
$form['term_node_tid_depth_negative']['#value'] = $form_state['input']['term_node_tid_depth_positive']; 

And that's it !

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.