Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
contextual filter: Taxonomy term: Term ID
I have tried all variations with specifying criteria, with one or more vocabularies, always allowing multiple values: There is never a difference between 'Filter to items that share all terms' and 'any terms'. Both of them filter to any.
Do I miss something? Pretty sure I was able to do so some month ago.
Comment | File | Size | Author |
---|---|---|---|
#14 | views-filter-by-all.png | 58.15 KB | zhuber |
#7 | Screen Shot 2012-08-31 at 11.47.25.PNG | 55.15 KB | jooplaan |
Comments
Comment #1
HitbyHi suldan,
Did you get this working?
Thanks
Comment #2
mzgajner CreditAttribution: mzgajner commentedWow, I came here looking for a solution, but my problem both options filter to all.
Comment #3
ygerasimov CreditAttribution: ygerasimov commentedI would like to reproduce the problem locally. Can you please guide how to set up the view and what is expected behavior and what we have instead?
Comment #4
dawehner@ygerasimov
You are doing really great work in the issue queue. Feel free to set the status to "postponed (needs more info)".
If noone responds for a long time we can close them all at once, which happens for many issues.
Comment #5
suldan CreditAttribution: suldan commented@ygerasimov
Thanks for taking a look:
1. We need a taxonomy with some terms (A and B)
2. 2 nodes each related to term A and B; 1 node related to only A
3. The view with:
a. relationship 'Content: Taxonomy terms on node'
b. argument '(term) Taxonomy term: Term ID' [default value: taxonomy ID from url; default filter from node page; reduce by vocabulary; Filter to items that share all terms
expected behavior: When viewing a node related to A+B the view should return one node (also related to terms A+B).
actual behavior: All nodes related to A or B are returned
Comment #6
esmerel CreditAttribution: esmerel commentedAre you sure you set the filter to 'and' not, 'or'? Check your settings in the filters.
Comment #7
jooplaan CreditAttribution: jooplaan commentedI could reproduce the bug. Filter criteria is set to 'AND', same configuration as in comment #5. Any solution is highly appreciated.
Comment #8
esmerel CreditAttribution: esmerel commentedComment #9
bdevore CreditAttribution: bdevore commentedJust ran into this myself. What you're missing is under the "More" tab on the contextual filter at the bottom of the modal window, select "allow multiple values".
Comment #10
esmerel CreditAttribution: esmerel commentedComment #12
dbrouard CreditAttribution: dbrouard commentedJust for you to know, I yet have the same problem, both options do the same 'Filter to items that share all terms' and 'any terms'.
My workaround is setting two contextual filters, one for every vocabulary.
Comment #13
zhuber CreditAttribution: zhuber commentedThis is actually not working for me.
I have 'Filter to items that share all items' and 'allow multiple values' selected.
If I inspect the args in a preprocess_views_view function I see that the args have the following:
3,5,18
Unfortunately, it is matching any item instead of matching all.
Comment #14
zhuber CreditAttribution: zhuber commentedNot trying to hijack the thread here, but both dbrouard and myself have the same issue.
When I select 'Filter to items that share all terms' and 'Allow multiple' it still shows items that match any (OR instead of AND).
My use case:
Taxonomy:
Automobile
- Car
- Sedan
- Coupe
- Truck
If I have my view block on a node with "Car, Sedan" selected my view will return results from nodes tagged with "Car", "Car, Coupe", etc. It does not limit to items with both "Car" AND "Sedan".
Attaching screenshots, here is the query:
As you can see, it is selecting any items in an array of IDs:
WHERE (( (field_data_field_categories.field_categories_tid IN('3', '5', '18')
Comment #15
zhuber CreditAttribution: zhuber commentedFound the issue.
I was using a taxonomy field as my contextual filter (field_category).
By switching to a 'Has taxonomy term ID' contextual filter, this functionality worked fine.