I am having trouble with the proper configuration of passing multiple taxonomy term selections through a page (which calls a view) and uses contextual filters to display only nodes that have, in this case, categories which match the ones i've multiple selected in the node.
I have a node with a taxonomy multiple select box (category). I select two categories.
I have a page that is used for that node's specific content type. It calls a view.
Presently that view is configured such that the view's contextual filter, as it is presented in pages, is:
CONTENT: HAS TAXONOMY TERM ID
and I select 'category'.
In views i have set up a contextual filter with these specs:
Content: Has taxonomy term ID
Specify validation criteria - Validator: taxonomy term
filter value type: term name converted to term id (I could use others, a few seem to work - my gut tells me I need the ..Terms ID separated by, or +)
and then undre more i've selected "allow multiple values"
I think the issue is in passing the arguments from the page to the view, so I thought I would try creating custom arguments - but this is completley lost on me.
its worth noting that there is ONE other contextual filter I pass before this - but it's working just fine because I dont need multiple values.
Any support would be greatly appreciated,
Thanks
Comment | File | Size | Author |
---|---|---|---|
#16 | view-bug.png | 31.62 KB | shahgm |
Comments
Comment #1
mhaamann CreditAttribution: mhaamann commentedMarking this as a bug.
I am also experiencing this.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedSame here. Trying to list users and using UID as contextual filter. 1 UID works just fine but when trying with multiple -> no records.
Actually SQL query won't event get executed with multiple filters (1,2,3 or 1+2+3).
Comment #3
Fazula CreditAttribution: Fazula commentedAs a beginner I find it hard to understand exactly how to do this, any help regarding best practices when adding more than one taxonomy term to a contextual filter will be appreciated.
Comment #4
othermachines CreditAttribution: othermachines commentedThe configuration below allows me to match on (for example)
mysite.com/publications/term/4
(just 4), ormysite.com/publications/term/4+7
(4 OR 7) ormysite.com/publications/term/4,7
(4 AND 7). So far so good, anyway.Drupal 7.x, Views 3
Display type: Page
Path: "publications"
First contextual filter: Global: Null
Second contextual filter: Content: Has taxonomy term ID
I could not get this to work with filter value type "Term name converted to term id" no matter what I tried. Not convinced it's a bug but it's certainly counter intuitive.
Cheers -
Comment #5
chrsnlsn CreditAttribution: chrsnlsn commentedI find it's helpful to find a couple test term id's to make sure a contextual filter is working so if I'm setting up a contextual filter for Content: Tags (field_tags).
I choose 'Provide default value' Type PHP Code. Then just throw a couple static tid's in there like so
return "15+19";
at least this will let you know if the view is spitting out the values you expect given known tid's
Comment #6
coolhandlukek2 CreditAttribution: coolhandlukek2 commentedSubscribe - problem for me too
Comment #7
Eleine CreditAttribution: Eleine commentedSame problem here. I have one contextual filter for term id (raw value from URL) which works perfect as long as I do not add my second filter, which is a PHP generated multiple-value argument which should negate nodes that has already been rendered on the page.
Is this bug tracked somewhere else? I find it strange that only the few people abouve should have reported this.
Edit: After changing "raw value from URL" to taxonomy id and then sending the id from a pages context, it works. The PHP output should of course not interfere with the raw value from URL option, but this seems to be a workaround in some cases when raw URL value can be avoided.
Comment #8
ssoulless CreditAttribution: ssoulless commentedIm experiencing the same of @othermachines if I pass 4,5 term ids as arguments or 4+5 it works ok but I could not make it work with term name. if you choose "term name converted to term ID" it works only with one sime taxonomy name for example if I pass "taxonomy name 1" as argument it works ok, but if I do something like "taxonomy name 1+taxonomy name 2" or "taxonomy name 1,taxonomy name 2" it just does not work.
So how to use multiple values with term names as arguments?
Comment #9
vchen CreditAttribution: vchen commented#4 worked for me! However, I changed it a bit to fit my needs. My contextual filter did not come from the URL so I didn't need to bother with the Global:Null filter.
Also, just by habit, I filled in When the Filter Value is NOT available section
Provide default value
Type: Taxonomy term ID from URL
Load default filter from term page
load default filter from node page that's good for related taxonomy blocks
Limit terms by vocabulary: select your vocab
Filter to items that share any term
Comment #10
jim005 CreditAttribution: jim005 commentedany update on this ? I'm facing to this same bug. :-(
Comment #11
xandermar CreditAttribution: xandermar commented+1 - same problems here. I experience with Views page (path: name/%/%). Trying to pass two variables, selected "RAW VALUE FROM URL" and selecting the PATH COMPONENT. Tried position 1, 2, 3, etc... nothing worked - defaulted on the first variable every time. For example, if path was "name/1/2" and I needed the variable "2", I'd select RAW with PATH COMPONENT "3" - didn't work ("Use path alias" unchecked). Views kept using the PATH COMPONENT 1 regardless of my changing it.
Comment #12
othermachines CreditAttribution: othermachines commentedHey, @xandermar. FWIW, I always have "Use path alias" checked when retrieving arguments from the URL.
Comment #13
xandermar CreditAttribution: xandermar commented@othermachines - Thanks.. But, I tried both with "Use path alias" (checked and unchecked). Doesn't work either way... :(
Comment #14
kimjanssens CreditAttribution: kimjanssens commented@xandermar Try:
NOT
- unfiltered value from url
- pathcomponent -> 1 or 2
- use path alias
IS
- Validationcriteria -> taxonomy term
- termname to termID
Comment #15
scaballeronavia CreditAttribution: scaballeronavia as a volunteer commentedHi from Bolivie, I have a solution, it works well for me.
Add context filter:
- Content: You taxonomy term ID (with depth)
- Allow multiple values check
- Filter value type: separated by + or
Great!
Comment #16
shahgm CreditAttribution: shahgm commentedI am having the same problem using Drupal 8.0.3 and no luck. I want to show two tags of the same fields i.e. Market = Enterprise OR Market = "user selection through expose filter(one value)".
I tried to design query with no luck as shown in the image. Also, tried by using allowing multiple selection. Then select Enterprise and some other selection, but no luck. Any help?
In 2nd option when i select one value, i get result for that selection. Upon selecting multiple values, start getting no result.
Thanks,
Comment #17
shahgm CreditAttribution: shahgm commentedin filters i want to add additional tag on top of exposed filter for taxonomy term. For example, in following image when user select particular market for example: Richmond, i want to show table with content that has Richmond or Enterprise tag on them.
Any suggestion to fix or work around would be greatly appreciated.
https://www.drupal.org/files/issues/view-bug_0.png
Thanks,
Shah
Comment #18
LendudeLooks more like a support request then a bug at first glance, moving to the right queue
Comment #21
KD Eric Depta CreditAttribution: KD Eric Depta commentedI have the same bug using a 'Fixed' default argument. No matter if you enter the values separeted by '+' or ',' the results are the same. The query does not change. It allways makes an IN (..,..,..) statement out of it.
In addition the query setting Distinct is not working as well.
Comment #22
erichomanchuk CreditAttribution: erichomanchuk commented@KD Eric Depta If you are using the contextual filter Content: Has taxonomy term ID (with depth) then the query will always us an IN operator for the statement. If you read the help text under the Allow multiple values if states "... Due to the number of JOINs it would require, AND will be treated as OR with this filter." so the multiple-value handling options - Filter to items that share all terms - Filter to items that share any term - Will both function only as an OR, which is somewhat confusing.
Comment #23
jzavrl CreditAttribution: jzavrl at NDP commentedIf anyone else is still having an issue with this, here is how you make it work.
Under "When the filter value is available or a default is provided" you need to select:
And then under "More" check "Allow multiple values", after that you can use multiple IDs such as 1+2 or 1,2.
Comment #25
axooh CreditAttribution: axooh commentedI have a similar issue. I configured the contextual filter as mentioned in the last comment, but the view shows only results for the first taxonomy.
For example for the path /view/1+2 only the elements with taxomony 1 are shown.
Comment #26
hudriThis is definitely a bug, contextual filters with multiple values and operators don't work as expected. It is not related to entity references or taxonomy terms, also multi-value base fields such as integers or plain texts can't be filtered correctly.
Comment #27
hudri(changing back to bug report)
Comment #30
rogerpfaffadding a related issue
Comment #32
wrg20 CreditAttribution: wrg20 commented+1 following
Comment #33
rogerpfaff@wrg20 You can follow an issue with the follow function in the right column of every issue. Right below the grey box.
Comment #34
portulacaI can confirm symptoms from #26.
So it seems that the OR operator "value_1+value_2" is working as expected, but there is no way to get the AND operator "value_1,value_2" working, it's just copying the OR case.
I'm seeing the same behavior in D7.
Comment #35
ccarrascal CreditAttribution: ccarrascal at Johnson & Johnson commentedI am having the same issue here, same as #26 and #34. I have tried also recommendations from #23, but I couldn't get it to work that way either.
I am always getting an OR instead of and AND.
I am using 8.6 core at this time.
Comment #36
liquidcms CreditAttribution: liquidcms commentedSlightly different issue; but likely related. If i allow multiple and use "taxonomy term name" validation; then if i pass multiple with +, i get no results. In other words it appears to try to validate the entire string "term1+term2".
This is with 8.7.10
Comment #39
ianchan CreditAttribution: ianchan commented@ccarrascal - how did you get the OR to work. Multiple taxonomy IDs does not work for me in contextual filter.
Comment #40
ccarrascal CreditAttribution: ccarrascal at Johnson & Johnson commented@ianchan, OR was working for me just following the steps in #23
Comment #41
dmezquia#23 works fine for me, I just think the "more" checkbok should be more visible to see it better.
Comment #44
robert_t_taylor CreditAttribution: robert_t_taylor as a volunteer and commentedThanks, @jzavrl! I can confirm that #23 works on Drupal 9.2.1.
Comment #47
smustgrave CreditAttribution: smustgrave at Mobomo commentedClosed as a duplicate