I am not sure if what I want to do is possible using Views.
I want to create a View in order to filter nodes by author and/or by city (City is a Taxonomy field). I have created it and it seems to work well in all cases except when the first contextual filter does not validate. I mean:
http://www.mywebsite.com/page/user1/barcelona shows all nodes of user1 from barcelona: works OK
http://www.mywebsite.com/page/user1 shows all nodes of user1: works OK
http://www.mywebsite.com/page/user1/undefined shows all nodes of user1: works OK
http://www.mywebsite.com/page/undefined/barcelona should show all nodes from Barcelona but it doesn't: it doesn't work
I attached the view in this bug. There are two contextual filters. First one is "Author uid":
- When the filter value is NOT in the URL: Display all results for the specified field
-
When the filter value IS in the URL or a default is provided:
- Specify validation criteria
- Validator: User
- Type of user filter value to allow: Only allow string usernames
- Action to take if filter value does not validate: Display all values...
And "City" filter:
- When the filter value is NOT in the URL: Display all results for the specified field
-
When the filter value IS in the URL or a default is provided:
- Specify validation criteria
-
Validator: Taxonomy term
- City
- Filter value type: Term name converted to Term ID
- Transform dashes in URL to spaces in term name filter values
- Action to take if filter value does not validate: Display all values...
Thank you in advance.
Comment | File | Size | Author |
---|---|---|---|
#8 | attention_all_filters.patch | 346 bytes | anewholm |
#7 | attention_all_filters.patch | 346 bytes | anewholm |
view.txt | 8.89 KB | Aljullu |
Comments
Comment #1
drupal12user CreditAttribution: drupal12user commentedI have the exact same problem. I have 4 contextual filters, and if one doesn't validate (for which i choose to display all values for that field if it doesn't validate), all the following filters are not taken into account. Could this be a Views bug?
However, a solution would be to use the "Exception value" in the ContextualFilter "When the filter value is NOT available" part. Instead of using "undefined" you can use the "all" value (or even "undefined" but you have to make "undefined" as "Exception value"). I think this is because, before checking the availability of the filter, Views checks if the provided value validates the existing Taxonomy terms?
Comment #2
Aljullu CreditAttribution: Aljullu commentedThank you. I didn't know about "Exception value" and I think I could solve my problem with this trick. Thank you again, you saved me to spend a lot of time writing SQL queries manually.
Comment #3
jpstrikesback CreditAttribution: jpstrikesback commentedJust trying to figure this out myself. I have multiple page displays with contextual filters all set to validate or show page not found like so:
blogs
blogs/author
blogs/author/year
blogs/author/year/month
blogs/year
blogs/year/month
Yesterday they worked, when author had no results but year did the display that validated showed...today they are clobbering each other, very very odd, and I'm wondering if what worked was intended on unintended behavior now!?
By clobbering I mean the behavior drupal12user details whereby if one validate action takes place subsequent displays don't get a chance to execute or something...
My workaround is adding a differentiating path component:
blogs/year
blogs/year/month
becomes
blogs/all/year
blogs/all/year/month
Comment #4
jpstrikesback CreditAttribution: jpstrikesback commentedGonna call this a bug and play with it a bit more today
Comment #5
jpstrikesback CreditAttribution: jpstrikesback commentedChanging this back, I see old views docs saying that the only thing choosing between matching paths in one view is access, I don't know if that's still the case, but it's likely.
Comment #6
anewholm CreditAttribution: anewholm as a volunteer commentedline 865 of views.inc:
else {
// determine default condition and handle.
- $status = $argument->default_action();
break;
}
should be:
else {
// determine default condition and handle.
$status = $argument->default_action();
+ if ($status !== TRUE) break;
}
Comment #7
anewholm CreditAttribution: anewholm as a volunteer commentedthis is the patch to add the $status check in
Comment #8
anewholm CreditAttribution: anewholm as a volunteer commentedjust try that again...
Comment #9
MustangGB CreditAttribution: MustangGB commentedClosing this as outdated to tidy up a bit around here. If you're still having problems with the latest release please create a new issue.
Comment #10
philsward CreditAttribution: philsward commentedI had a similar issue as described.
Oddly, I deleted all of the contextual filters and re-created them again. Then it "magically" worked. I had this problem on two different view pages within the same view. It makes me wonder if something didn't save properly which corrupts the DB and deleting then re-creating the contextual filters saves it proper.
I could be grasping at straws in a complete coincidence too...