You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the fieldtype in a field called groupAddress works brilliantly, unless Google Maps can't find the location.
{% set location = craft.request.getParam('location') %}
{% set params = {
address: location,
distance: 10,
unit: 'miles'
} %}
{% set locEntries = craft.entries.groupAddress(params).section('groupEntries').relatedTo(service).order('distance asc') %}
If I enter something like "lalalala", which returns no results on google maps, this then throws the common "Column not found" error.
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'distance' in 'order clause'.
If I leave off the .order('distance asc') parameter, then it doesn't throw an error, but it just shows all results. Outputting {{ locEntries | length }} returns the correct amount of results (even showing 0 when no results are found close to the entered location), but then if entering e.g. lalalala again, it shows the total of all entries, when I'd expect 0.
I can't see any way to check if the location is a valid one before trying to filter the results by it, else it'd be a simple conditional workaround, though obviously it returning 0 results and not throwing an error would be preferable.
The text was updated successfully, but these errors were encountered:
Any solution to this? Getting the same error, but there's no way to check if Google returns results before doing the select with .order('distance asc') added to the query...
Sorry for the delayed reply on this. Was out with some serious health and personal issues most of last year. Im starting to get back into full health again and working my plugins. I have been working with a couple other users getting this same issue address. From what I can tell, the plugin code is working in the most recent 2 master branches. However, I think you need to conditionally order by distance only if there is an address available. Something like this...
Using the fieldtype in a field called groupAddress works brilliantly, unless Google Maps can't find the location.
If I enter something like "lalalala", which returns no results on google maps, this then throws the common "Column not found" error.
If I leave off the
.order('distance asc')
parameter, then it doesn't throw an error, but it just shows all results. Outputting{{ locEntries | length }}
returns the correct amount of results (even showing 0 when no results are found close to the entered location), but then if entering e.g. lalalala again, it shows the total of all entries, when I'd expect 0.I can't see any way to check if the location is a valid one before trying to filter the results by it, else it'd be a simple conditional workaround, though obviously it returning 0 results and not throwing an error would be preferable.
The text was updated successfully, but these errors were encountered: