I've got a node of type "page" and another of type "article". Each has an identical taxonomy field including term A and child terms AA and AB. I need to render blocks on page nodes that show article nodes. I want to match on terms only the terms AA or AB, not on the parent term A. I have B and C out there, but now it's just alphabet soup.
I'm slamming my face in my keyboard trying to make the "Content: Has taxonomy term ID" or the "Content: Has taxonomy term ID (with depth)" contextual filters work for me. In either scenario, I can't get the filters to read the depth of the taxonomy tree properly. Especially with the depth filter, I get closest by setting the filter to read the vocabulary from the node and depth of -1, but it still wants to pull results that also match the top level term. I just can't let that nasty little filter get away with that.
Which filter/contextual filter/relationship is supposed to do this? Am I fighting against a dev version that's just not ready yet? There is clearly something simple that I'm missing. Thanks!
Comments
Comment #1
neoglez commentedLet's see, if you want to match nodes of a specific type (articles) that have specific terms (AA or AB) regardless of the depth (if that's what you mean):
First consider that the relations in views are no longer implicit (more on this in the help or issues queue).
Second: add a filter Content: Type & configure it.
Third: add a filter (considering that you have the right relationship) Content: Has Taxonomy term & configure it, here is important that you Select terms from vocabulary X (AA and AB in your case).
If this is not the solution try to be more explicit.
Comment #2
seaneffel commentedThe node type is irrelevant to the question, I suppose. Here's the core of my question. If my vocabulary looks like this:
animals
-dog
-cat
In my case, all nodes MUST contain both a parent and child term. But I want to show related nodes where ONLY the child term matches and NOT the parent. That means I need results for nodes tagged animal+cat, but exclude nodes that are animal+dog.
The "Content: Has taxonomy term ID" contextual filter returns nodes that match any term within the vocabulary. I get results for cat-tagged nodes, but also any nodes that are animal-tagged (which includes dog-tagged nodes). So that one is no good.
The Content: Has taxonomy term ID (with depth) contextual filter should be configurable to exclude the parent terms, right? When modifying the depth value I should be able to include or exclude levels of the vocabulary but the results just aren't popping out. No matter what +/- 1, 2 or 3 is set, I can only get all terms matched or no terms.
For the life of me, I can't figure out how to match only a specific term level in a vocabulary.
Comment #3
neoglez commentedLet's see
Version 1
If your nodes MUST CONTAIN both a parent and a term (assumed *all* nodes are tagged with animals + X where X is in {dog, cat})
Somethig like:
Node 1 animals + dog
Node 2 animals + cat
Why caring about animals in the first place??
Version 2
If your nodes MUST MATCH both parent and child: just add two contextual filters: one for the parent and one for the child.
Version 3 (I think this is what you mean)
"Find all nodes that has a term X AND X is the child of other term (undefined, don't care wich is)".
There could be (VERY dirty) work-arounds (e.g. configure so many filters as parent-child combinations you have), note that the restriction is to have a relation parent-child, you just don't want nodes with the term X, you want also this term to be the child of someone, basically this is a Feature request, so change the status correspondly.
Comment #4
DjebbZ commentedNoeglez has pretty much covered every solution possible. As his last answer shows, your question isn't very clear, that's why he had to give you 3 answers. I'll add mine : try to write your own taxonomy filter handler. I would try to extend views_handler_filter_term_node_tid.inc, located in views/modules/taxonomy
Comment #5
suldan commentedYou could also allow multiple values for the filter 'content:has taxonomy term id'. Load default filter from node page. Limit terms by vocabulary. Filter to items that share all terms. No specification of validation criteria needed. No additional relationship needed. ALLOW MULTIPLE VALUES.
On a node tagged with animals and dogs you will get all related nodes also tagged with animals and dogs.