Jump to content

Promote user input zip code location results to top of list


jds43
 Share

Recommended Posts

Hello,

I'm using an API to return a collection of zip codes within a radius of a particular zip code the user will input. These will populate a list of locations, but I'm having trouble promoting the zip code input by the user to the top of the list. Sort isn't working at all.

ZIP is the location page zip code field.
$city_or_zipcode is the sanitized input.
$selector is the decoded JSON response as string for zip codes separated by pipes.

$producers = $locations->children("(ZIP=$city_or_zipcode), (ZIP=$selector), template=producer, limit=24");

I've even prepended the searched user zip code to $selector and it doesn't help either.

Any ideas?

Link to comment
Share on other sites

Ended up removing the searched user zip code from the $selector response and opted not to paginate. Hopefully it's good enough.

$target = $pages->find("ZIP=$city_or_zipcode, template=producer");
$range = $find_help->children("ZIP=$selector");
$producers = $target->add($range->find("limit=24"));
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...