Search entries based on location data in member fields
I'm building a site where each member will have a location (lat/long) as one of their custom member fields. They each have several items for sale, which are channel entries. I want to be able to search those entries with keywords/categories, but also within X miles of a specified location – eg "show me all blue chairs within 50 miles of me".
Can Low Search's Distance Filter be used like this, to return channel entries based on custom member fields of their author?
Replies
cwcrawley 7 Jan 2015 13:25
Hi Frank,
My name is Carl and I'm manning the support desk while Low is out of action for the next few days.
From recollection, the distance filter works (and Low search in general) works on channel entries only, so this wouldn't work in your instance I'm afraid.
What you could do though, would be to use something like Zoo Visitor to leverage channel functionality for member data and that way you could potentially fashion something which would do the job - it would require some inventive work though!
I hope this helps.
Regards,
Carl
Frank Harrison 7 Jan 2015 13:53
Thanks for the quick response Carl. I'll take a look at Zoo Visitor, I've not used it before.
I guess the other way I could do it would be to automatically copy each members location into channel entry custom fields whenever they publish something. But that means that if they change their location they would have to update each entry too.
Looks like there might not be an ideal off-the-shelf solution to this one...
cwcrawley 7 Jan 2015 13:59
Hi Frank,
Your suggestion of putting the lat/lng in as custom hidden fields each time an entry is added would certainly resolve your problem.
A custom add-on could be written to hook into the saving of member data to iterate through and update all the appropriate entries if you have budget - It wouldn't be a huge undertaking.
Alternatively, Zoo Visitor might resolve your issue but like I said, some really inventive coding would be needed - you'd first have to get all the zoo visitor entries within a 50 mile radius and then pass this into the search results, only getting results which match the criteria where the author is the results from the previous query.
Frank Harrison 7 Jan 2015 14:11
Thanks Carl, I'll have a think about it. I suspect copying location into each entry is going to be the most flexible – and maybe the fastest in terms of delivering search results. I've not built add-ons but maybe this is a good project to start on... Thanks!
cwcrawley 7 Jan 2015 14:12
Great, thanks Frank. If I can be of any help or you get stuck and would like some assistance with the add-on, please feel free to drop me an email carl[at]madebyhippo[dot]com
Good Luck with it all
Regards,
Carl
Frank Harrison 7 Jan 2015 14:34
Thanks Carl :)