Download the PHP package winter/wn-location-plugin without Composer
On this page you can find all versions of the php package winter/wn-location-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download winter/wn-location-plugin
More information about winter/wn-location-plugin
Files in winter/wn-location-plugin
Package wn-location-plugin
Short Description Location plugin for Winter CMS
License MIT
Homepage https://github.com/wintercms/wn-location-plugin
Informations about the package wn-location-plugin
Location Plugin
This plugin adds location based features to Winter CMS.
Supports:
- Easily add Country and State to any model
- Form widget for address lookups (Google API)
Installation
This plugin is available for installation via Composer.
After installing the plugin you will need to run the migrations and (if you are using a public folder) republish your public directory.
Google API key requirement
As of June 22, 2016 the Google Maps service requires an API key. You may generate a key from the following link:
Copy the key and enter it in the Settings > Location settings area. If you find the address finder is not working, you may need to enable the Places API and the Maps JavaScript API.
Add Country and State to any model
This plugin provides an easy way to add location fields, country and state, to any model. Simply add these columns to the database table:
Then implement the Winter.Location.Behaviors.LocationModel behavior in the model class:
This will automatically create two "belongs to" relationships:
- state - relation for Winter\Location\Models\State
- country - relation for Winter\Location\Models\Country
Back-end usage
Forms
You are free to add the following form field definitions:
Lists
For the list column definitions, you can use the following snippet:
Front-end usage
The front-end can also use the relationships by creating a partial called country-state with the content:
This partial can be rendered in a form with the following:
Short code accessors
The behavior will also add a special short code accessor and setter to the model that converts country_code
and state_code
to their respective identifiers.
ISO 3166-1 accessors
The behavior will also add the ISO-3166-1 values as accessors to the model (data sourced from the league/iso3166 package).
Availables accessors are iso_name
(country name), iso_alpha3
(three-letter code), iso_numeric
(three-digit code), iso_currencies
(three-digit currencies code) and iso
(array of all iso attributes).
Address Finder Form Widget
This plugin introduces an address lookup form field called addressfinder
. The form widget renders a Google Maps autocomplete address field that automatically populates mapped fields based on the value entered and selected in the address.
Available mappings:
- street
- city
- zip
- state
- country
- country-long
- latitude
- longitude
- vicinity
Available options:
You can restrict the address lookup to certain countries by defining the countryRestriction
option. The option accepts a comma separated list of ISO 3166-1 ALPHA-2 compatible country codes (see: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2).
Usage:
All versions of wn-location-plugin with dependencies
composer/installers Version ~1.0
winter/wn-backend-module Version ~1.2.8|dev-develop
league/iso3166 Version ^4.3