diff --git a/CHANGELOG.md b/CHANGELOG.md index 63f0997..ca60072 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 1.0.1 - 2019-08-31 +### Added +- Added installation instructions to readme +- Added Twig filter to output coordinates in front-end +- Added Twig documentation to readme + + ## 1.0.0 - 2019-08-31 -### Added -- Initial release +### Added +- First version of the Craft plugin. +- Include plugin icon +- Include Craft license +- Add preview to readme (#1) +- Draggable marker on a Google Map +- Includes searching through Google Places API +- Google key configurable in field setting + diff --git a/README.md b/README.md index 4d4024f..50d3f52 100644 --- a/README.md +++ b/README.md @@ -4,3 +4,22 @@ Pick a GPS location for an entry ![PluginImpression](https://user-images.githubusercontent.com/3450011/64065265-e3cbc680-cc0b-11e9-89fc-ed682123b109.gif) +## Installation + +To install the plugin, follow these instructions. + +1. Open your terminal and go to your Craft project and tell composer to install the plugin +```composer require nthmedia``` + +2. Activate the plugin in Craft through the command line or through the Control Panel under Settings → Plugins +```./craft install/plugin entry-gps-coordinates``` + +3. Add a Coordinates field under Settings → Fields and add this field to a Section under Settings → Sections + +## Usage in Twig + +``` +{{ entry.fieldName | coordinates }} => 47.11736635136284,12.82762888348384 +{{ entry.fieldName | latitude }} => 47.11736635136284 +{{ entry.fieldName | longitude }} => 12.82762888348384 +``` \ No newline at end of file diff --git a/composer.json b/composer.json index a95ff3d..08ead46 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "nthmedia/entry-gps-coordinates", - "description": "Select a GPS location for an entry", + "description": "Entry GPS Coordinates plugin for Craft CMS 3.x", "type": "craft-plugin", "version": "1.0.0", "keywords": [ diff --git a/src/EntryGpsCoordinates.php b/src/EntryGpsCoordinates.php index 087da3e..058e831 100644 --- a/src/EntryGpsCoordinates.php +++ b/src/EntryGpsCoordinates.php @@ -11,6 +11,7 @@ namespace nthmedia\entrygpscoordinates; use nthmedia\entrygpscoordinates\fields\EntryCoordinates as EntryCoordinatesField; +use nthmedia\entrygpscoordinates\twigextensions\EntryGpsCoordinatesTwigExtension; use Craft; use craft\base\Plugin; @@ -78,6 +79,9 @@ public function init() parent::init(); self::$plugin = $this; + // Register Twig extension + Craft::$app->view->registerTwigExtension(new EntryGpsCoordinatesTwigExtension()); + // Register our fields Event::on( Fields::class, diff --git a/src/twigextensions/EntryGpsCoordinatesTwigExtension.php b/src/twigextensions/EntryGpsCoordinatesTwigExtension.php new file mode 100644 index 0000000..d59c012 --- /dev/null +++ b/src/twigextensions/EntryGpsCoordinatesTwigExtension.php @@ -0,0 +1,100 @@ +