Hi all,
I'm racking my brains and posting here as an absolute last resort - I created a new thread because I am using the lastest version of the location module code.
In approximately January, I created a proximity search and it was working beautifully with Canadian postal codes, I think I used location 6.x-3.1-rc1. However, we didn't have the data ready for all nodes so I just disabled the link but kept the view. I then migrated the site from a subdomain to its own domain.
Somewhere along the line, I upgraded the module from 6.x-3.1-rc1 to a new version. When I re-enabled the search view yesterday, it no longer returned results. I read through http://drupal.org/node/662892 and http://drupal.org/node/321114 and tried the suggestions but no luck. I did revert back to location 6.x-3.x-dev from Jan 23, 2010 and applying the patch from http://drupal.org/node/662892 but still no luck.
I'm pulling my hair out trying to figure out what's wrong. Does anyone have any ideas? here is the code from views:
SELECT location.lid AS lid,
node.title AS node_title,
node.nid AS node_nid,
'Unknown' AS location_distance
FROM location location
LEFT JOIN location_instance location_instance ON location.lid = location_instance.lid
LEFT JOIN node node ON location_instance.vid = node.vid
WHERE (1=0) AND (node.status <> 0)
I have the zipcodes table setup in the database and it was working before. I also tried exporting it, dropping the table, and re importing it but no luck.
Any help would be HUGELY appreciated!
pete
Comments
Comment #1
yaworsk commentedUPDATE
Got it working!
Here's what I did, no idea what did it and I dont have time to test right now but I didn't want people wasting time on this.
1. Disabled location module and all associated modules
2. Uninstalled the location module and all associated modules.
3. Reinstalled the Location module.
4. Recreated postal codes in the zipcodes table
5. Created a Location view
6. Only added the location field -- did not add the distance / proximity field
7. Added an argument: location: Distance/proximity which had the following,
Action to take if arg not present, display all
basic validation
coordinate type: postal code
distance unit: kilometers
method: circular
8. Added a filter for node published, yes
9. Added exposed filter for location: Distance / Proximity with the following:
Operator: proximity (circular)
origin: postal code (assume default country) -- set the default in location settings
distance: 100 kilometers
optional: unchecked -- force the postal code to be input
filter identifer: distance
And bam, it worked. I hope this helps someone. When I had the distance / proximity field in, I was still seeing 'Unknown' AS location_distance in the view query despite choosing provided by user.
Pete
Comment #2
PacmanZ commentedA small tip just in case: double check the geocoding configuration.
Same thing just happened to me. It turned out that no geocoding service was selected (none is by default) for my country in Location configuration, causing users to not have coordinates filled in and in turn the view filter to have no data to calculate from. This resulted in invalid SQL queries such as yours.
It was just a checkbox to tick, but really not obvious to find out as the filter gives no clue.
@yaworsk: I can't see the point of having Distance both as an argument and as a filter. Does that make any difference ? I guess this could be what breaks the distance field display.
Comment #3
djmabo commentedtry this: file handlers/location_views_handler_filter_proximity.inc on line 297
$this->query->add_where($this->options['group'], "1=0"); change to $this->query->add_where($this->options['group'], "1=1");
Comment #4
djmabo commentedComment #5
PacmanZ commentedNo offense intended, but #3 does not fix anything, it just hides the fact that something is wrong in the data or in the view configuration. While it might prevent the results from being empty, there will anyway be no result matching the proximity filter, which breaks the intended behaviour of yaworsk view.
It seems that the line you mention gets run when the coordinates of the origin cannot be found. Obviously in this case distance cannot be calculated, and thus can be assimilated to a NULL value in the DB. So it kinds of make sense to return nothing, but it's not self-explanatory for sure.
Maybe a parameter in the filter configuration could determine if everything should be returned or nothing, a bit like 'Action to take if argument is not present' in arguments parameters.
Comment #6
chrsc commentedThanks for this post, especially for posting the solution once it was working again, its exactly what happened to me too. The cause of my issue was migrating from one server to another, not a domain/sub-domain, there must be some settings that need updating during a migration. Would love to know what they are for next time so I don't need to to the uninstall/re-install method of fixing.
Comment #7
yaworsk commentedRan into this issue again setting up a new site with location and realized my solution in #2 was ridiculous... not a solution at all, it only fixed the issue because postal code was no longer optional.
This is cross linked to http://drupal.org/node/505596 and the patch solves this issue and has been committed to head -- however, a new stable version with this release hasn't been released yet so you'll need to manually patch 6.x-3.1 or below.
Pete