I have a page View with a set of filters:
1. node type
2. distance/proximity (exposed)
3. a) city b) province/state (both exposed)
The default value for distance is 100 km and the postal code defaults to empty. Likewise the city and province/state default to empty. If I enter a postal code the view returns the data as I expect (great!). If the postal code is empty and the distance is set to 0 km and I enter a city or province/state or both, the view returns data as I expect (great!).
But if I go to the page View (presented with the defaults: postal code, city, province/state empty with distance set to 100 km) and enter a city or province/state or both, the view returns nothing. The behaviour I would like (expect) is that because I did not enter a postal code for the proximity filter it should not be enacted. Basically the user experience should be (in my case) to either do a proximity search based on postal code or to simply filter nodes based on a combination of city and province/state.
The reason that I don't get the behaviour I desire when I enter the city or province/state or both is because AND (1=0) is appended to the SQL query when the postal code field is empty but the distance field is set to the default of 100 km.
Can anyone propose a solution for this or brainstorm with me?
One potential workaround is to set the default distance to 0 km but that unfortunately returns all of nodes of the type I specify in the filter when I initially navigate to the page (as no filters are set, except for the node type). This is not ideal because the number of nodes is large and I'd ultimately like to set this view to gmap, which would mean that all of the nodes would by default be plotted on the map (until the other filters are set). I find that all 1500 nodes plotted on the map is incredibly slow in my current environment (if there is some way around this slow issue I'd also love to hear it, beyond jumping off shared hosting). Because of the slowness of having 1500 nodes plotted on a gmap, I'd need to default behaviour to be that of an empty set until filter fields are filled by the user.
Thanks for any insight you can offer.
Cheers.
Comments
Comment #1
sgallen commentedEDIT: the default behaviour in the workaround I describe (default distance to 0 km) is actually to plot the number of nodes specified in "Items per page". So my worry regarding plotting all of my nodes by default when the default distance is 0 km is unfounded, but this behaviour is still unsatisfactory. At a bare minimum I need no results returned by default.
Comment #2
yesct commenteddoes this help?
http://drupal.org/node/662892#comment-2884624
Comment #3
sgallen commentedhttp://drupal.org/node/662892#comment-2884624 The comment you specify was what initially led me to realizing that the behaviour I was seeing was due to AND (1=0) being appended to the query but it unfortunately doesn't lead me to a solution.
Comment #4
yesct commentedI recommend making a post in that other issue pointing to this issue, and asking people there if they have already fixed the AND (1=0) problem... or try the latest patch over there and see if it fixes things for you.
Comment #5
not_Dries_Buytaert commentedI think that this is already was being discussed here: http://drupal.org/node/505596
Please, correct me if I am wrong by changing the status back again.