All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Question about the 'Distance' filter in Low Search

Doug Henderson 7 Dec 2015 16:13 question, complete

Interested in using 'Low Search' as a distributor lookup. Would need the visitor to enter a zip code and be shown a list of distributors within a certain radius of that zip code. I can write a plugin to get latitude and longitude for the entered zip code. But the 'Distance' example in your docs shows latitude and longitude hardcoded in the {exp:low_search:form} tag. Would I be able to use a zip code input field in your form tag?

Replies

  1. Low 7 Dec 2015 16:27

    The way I'd do it, is to add a field called 'zip' to your search form like so:

    <input name="zip">


    ...which gives you a 'zip' parameter to work with. Then, create an extension that uses the low_search_pre_search hook, where you can get to the value in the $params array that is passed on.

    You can then do your zip code to lat/long values calculation and set the distance:from parameter, which the Distance filter will use.