Distance from: lat lng field in channel entry
Hi, I'm using low search to create a store locator. The results page displays a list of stores within x miles of the searched location. Everything works great.
Withing the results I have a view more link that takes you to a details page showing the stores full detials.
What I'd like is to list the store within x miiles of the store you are currently viewing. I can't seem to get this to work?
Thanks
Wayne
Replies
Low 4 Apr 2018 15:58
What template code are you using now?
Wayne 4 Apr 2018 16:06
To get the store details I'm using a channel entries tag
{exp:channel:entries channel="store" url_title="{segment_3}" limit="1"}
Store details
{/exp:channel:entries}
I'm looking to show a list of stores that are close the store you are viewing. I'm using the code below outside of the channel entries tag.
{exp:low_search:results
channel="store"
distance:to="lat_lng"
distance:from="{lat_lng}"
distance:unit="km"
}
<p>{title} is {low_search_distance}km away.</p>
{if no_results}
<p>Sorry, nothing found within a {low_search_distance:radius}km radius.</p>
{/if}
{/exp:low_search:results}
Not sure if this is the best way to go about achieving this.
P.s: if I hard code the lat lng in the distance:from param it works.
Low 4 Apr 2018 20:13
Well, the {lat_lng} variable is probably not parsed, as it needs to be inside the channel:entries tag. You can work around it by using an embed for the Results tag, and using an embed variable to pass through the lat_lng value.
Wayne 5 Apr 2018 08:38
Thanks, that's worked.