How to add distance (radius) search for directory items
You incorporate a search into a custom module so that visitors can enter a zip code and a distance to locate items that are located within that radius. This search can simply list items within that radius, or with additional work, add Google mapping into the site.
To add a simple radius search to a custom module:
- In the Green interface, Toolbar module, turn on the Google module, if it is not already turned on.
- In the Green interface, Toolbar module, add a new custom module.
- On the custom module configuration page, select the Geocode the address field for radius searches (requires Google Account)" - Google account only require for Google maps checkbox.
- Create a custom module with the predefined address field.
- In the Green interface, switch to the Layouts module, Modules tab, and view the custom module layouts.
- Create or edit a search layout that you want to use for the radius search.
- In the first Output Method field, select "Radius - Select max distance from fields list, input is an address text box".
- In the first Fields list, enter the predefined search distances where the first value is the distance in miles and the second value is the displayed value that a visitor selects. For example:
- Change the output method for the first condition to "Radius - Select max distance from fields list, input is an address text box"
- In the HTML layout field, enter the html you want to use to display the search. Note that the displays the drop-down list where visitors select the distance and is the text field where the visitor enters a zip code. For example:
<div class="searchradius">Search within of zip or postal code <input type="submit" name="submit" value="Search" /></div>
- Save the search layout.
- Insert the search layout in the appropriate custom module lister layout.
- In the Blue interface, make sure to add items with the addresses entered.
- Test the lister layout on the site.