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.

Files: 
CommentFileSizeAuthor
view.txt8.89 KBAljullu

Comments

drupal12user’s picture

I 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?

Aljullu’s picture

Thank 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.

jpstrikesback’s picture

Just 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

jpstrikesback’s picture

Version:7.x-3.3» 7.x-3.5
Category:support» bug

Gonna call this a bug and play with it a bit more today

jpstrikesback’s picture

Category:bug» support

Changing 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.