Filter just on taxonomy depth
Summit - June 19, 2009 - 20:26
| Project: | Views |
| Version: | 6.x-3.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | won't fix |
Description
Hi,
I read the module and discussion on: http://drupal.org/node/271833 and great this is working!, but I would like a more simple filter.
Would it be possible to filter ONLY on taxonomy depth. After choosing vocabulary NOT having to choose terms. Just filter on the results which have a certain hierarchy (depth) in the vocabulary?
So using for this filter 2, will give me any nodes which have the depth of 2 (diagonal through this vocabularies).
Thanks a lot in advance for considering this filter.
Greetings, Martijn

#1
Hi,
I tried another approach to get the filter working through php, using the arguments php possibilities. But it doesn't work.
I may be doing something wrong. Please anyone know how to get a filter using arguments (so a dynamic filter)?
See attached picture for what I tried.
Greetings,
Martijn
#2
set to version 3.
#3
trying php-code underneath, but not succesfull yet.
// Show only filtered taxonomy term through $argument if ($argument) {drupal_set_message(var_export($argument, 1));
$tmpterms_0 = taxonomy_get_term_by_name($argument);
$view->display_handler->override_option('term_node_tid_depth' array(
'value' => $tmpterms_0[0]->tid,
));
}
Return $argument;
Greetings, Martijn
#4
Trying code with depth = '2' to filter to get only the terms with the depth of 2, but still not working :(, see:
// Show only filtered taxonomy term through $argumentif ($argument) {
drupal_set_message(var_export($argument, 1));
$tmpterms_0 = taxonomy_get_term_by_name($argument);
$view->display_handler->override_option('term_node_tid_depth' array(
'value' => $tmpterms_0[0]->tid, 'depth' => '2',
));
}
Return $tmpterms_0[0];
#5
subscribing...
#6
This is a duplicate of http://drupal.org/node/271833 which has since been fixed.
#7
Hi,
This is NOT a duplicate of http://drupal.org/node/271833 . I have that issue working. This is another feature request to not have to choose specific terms, but ONLY filter on taxonomy depth.
So please do not handle this as duplicate before reading everything.
Feature request:
Would it be possible to filter ONLY on taxonomy depth. After choosing vocabulary NOT having to choose terms. Just filter on the results which have a certain hierarchy (depth) in the vocabulary?
So using for this filter 2, will give me any nodes which have the depth of 2 (diagonal through this vocabularies).
Thanks a lot in advance for answering this feature request. It would be great if it could be done by phpcode within filtering on taxonomy terms, while than flexibility is awesome.
Greetings,
Martijn
#8
The way the data is structured in the database, this isn't really possible. Depth isn't stored as a number; you have to climb the tree to figure the depth out. It's vaguely possible that a customized filter could be written to support it, but I'm not going to write it, and I'm not particularly interested in including it with Views because I find it likely that such a filter would be riddled with problems.
#9
Hi Earl, Thanks for your update! And depth only within one vocabulary, so choose a vocabulary and then get only the terms with a certain depth?
Greetings, Martijn
#10
Unfortunately, the database doesn't intrinsicly know what the depth is. In order to determine the depth, it has to link in the term_hierarchy table repeatedly and test to see if there's data there. This creates ugly, hard to manage queries and I don't know if they'd really work in all situations. I've *just* added a taxonomy term relationship in CVS. It may be possible using that and the taxonomy: parent relationship to write a view that can check for items that have a certain depth by chaining parents to the right number and making sure that there is a result on the 2nd parent and not on the 3rd.
#11
Hi Earl,
that sounds interesting..will try the term-relationship when I am home next week again.
Greetings, Martijn