Let's say you create a simple node view with "Node: Title" and "Taxonomy: Term" fields.
The query is then:

SELECT node.title AS node_title,
term_data.name AS term_data_name,
term_data.vid AS term_data_vid,
term_data.tid AS term_data_tid
 FROM node node 
 LEFT JOIN term_node term_node ON node.vid = term_node.vid
 LEFT JOIN term_data term_data ON term_node.tid = term_data.tid

When you want to limit terms, you may then use "Taxonomy: Term" filter, that will add to the query:

WHERE term_node.tid IN (TID1, TID2)

This makes sense.
But then you use "Taxonomy: Term ID (with depth)", this adds:

WHERE node.vid IN (
  SELECT tn.vid FROM term_node tn
    LEFT JOIN term_hierarchy th ON th.tid = tn.tid
    LEFT JOIN term_hierarchy th1 ON th.parent = th1.tid
  WHERE tn.tid  = TID
    OR th1.tid  = TID
  )

When you would expect something like:

WHERE term_node.tid IN (
 SELECT th.tid FROM term_hierarchy th
  LEFT JOIN term_hierarchy th1 ON th.parent = th1.tid
 WHERE th.tid = TID
  OR th1.tid = TID
)

So it seems that a "Taxonomy: Term ID (with depth)" is missing.
And shouldn't the current "Taxonomy: Term ID (with depth)" be named differently?
Or maybe I'm missing something...

CommentFileSizeAuthor
#4 views_more.zip2.92 KBanrikun

Comments

anrikun’s picture

Category: support » feature
anrikun’s picture

Title: Taxonomy: Term : possible missing filter with depth? » "Taxonomy: Term ID (with depth)" name is confusing/inconsistent across filters and arguments
Category: feature » bug
Priority: Normal » Minor

Deleted.

anrikun’s picture

Reverting.

anrikun’s picture

Title: "Taxonomy: Term ID (with depth)" name is confusing/inconsistent across filters and arguments » Taxonomy: Term ID (with depth) : filter on term_node, not on node
Assigned: Unassigned » anrikun
Category: bug » feature
Priority: Minor » Normal
Status: Active » Needs review
StatusFileSize
new2.92 KB

Attached is a quick written module that adds the missing filter handler described in this issue, and the corresponding argument handler.
It would be great if maintainers could have a look at it.
I am sure the way the module is written could be improved, without using a subquery, but I don't really understand join helpers as they are not documented.
If maintainers are interested in this feature, I am OK to write a patch but I would need some info about the undocumented helpers of the API.
Let me know.

anrikun’s picture

kenorb’s picture

TimelessDomain’s picture

#4 looks good. This should be added directly into the views module.
As D7 represents the move towards entities, views should plan on allowing the same types of arguments and filters on all entities. Taxonomy: Term ID (with depth) in taxonomy views is a good step towards this. Next Taxonomy: Term ID (with depth) on users & entities (may already be available?).

Anonymous’s picture

(cross posted: #903438: Let taxonomy views have a Term ID with depth as well)
The behavior of "Taxonomy Term ID (with depth)" still exists in Views 3, but it is now called something different. Instead look for, "Content: Has Taxonomy Term ID (With Depth)". It's in the content not taxonomy section of contextual filters.

In my use case, in order to select nodes with the child of a given term argument, I had to do the following:
1. Create a term relationship (named it term).
2. Added the term ID with depth filter.
3. Views automatically also created a contextual filter for Term using the relationship created earlier. I deleted this.

mustanggb’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)