The aim of this fieldtype is to provide an easy way to list UK towns and regions for use in select fields and templates.
Put the englishplaces
folder into your craft/plugins
folder and install in the admin area.
Installation might take a few seconds due to table population
Choose English places
when you create a new field and choose one of the options:
- Towns Will display a dropdown of towns grouped by region
- Regions Will display a dropdown of regions
If you choose towns, the list pretty large, which if you don't want all of the towns you can limit it by region or country.
When using this fieldtype in your templates, you will be given an instance of Englishplaces_PlaceModel
which you can use to get various bits of information about the place you have selected. Available attributes are:
postcode
- The first set of chracters from postcode i.e LD7eastings
- A number representing eastward distance on a mapnorthings
- A number representing northward distance on a maplatitude
- The general latitude of the placelongitude
- The general longitude of the placetown
- The town name in the place, if you have selected a region then this will be the first one in the databaseregion
- The region the place is incountry
- The country of the placecountryCode
- A code representation of the country e.gWLS
,ENG
,SCT
Parameters you can use are:
town
- Get an array of townsregion
- Get an array of regions
For the second arguments you can pass a comma seperated string for either if you only want to display certion regions or countries.
You can see a complete list of available filters here
{% set places = craft.ukplaces.get(
'town',
{
regions: 'Essex, Surrey',
countries: 'England'
}
) %}