From 93e31675467d3ab751837c89316876b7fe3cc90e Mon Sep 17 00:00:00 2001 From: mak001 Date: Mon, 19 Jun 2017 13:05:17 -0500 Subject: [PATCH 1/3] updated docs - includes example of requiring a different script. --- docs/en/code/index.md | 44 +++++++++++++++++++++++++++++++++++++++++++ docs/en/index.md | 4 +++- 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 docs/en/code/index.md diff --git a/docs/en/code/index.md b/docs/en/code/index.md new file mode 100644 index 0000000..935a14c --- /dev/null +++ b/docs/en/code/index.md @@ -0,0 +1,44 @@ +#Extending + +To change how the front-end javascript displays the map the custom script with the unique id `locator_map_init_script`. +This example shows how to reference custom templates and a custom data location. It is recommended to copy the custom script from the [Locator Controller](../../../code/pages/Locator.php#L273-L298) and modify it. + +```php +$load = 'autoGeocode: false, + fullMapStart: true,'; +$kilometer = ($this->owner->data()->Unit == 'km') ? "lengthUnit: 'km'" : "lengthUnit: 'm'"; +$modal = ($this->owner->data()->ModalWindow) ? 'modalWindow: true' : 'modalWindow: false'; + +Requirements::customScript(" + $(function(){ + $('#map-container').storeLocator({ + {$load} + dataLocation: '{$this->owner->Link()}SimpleXML.xml', + listTemplatePath: '{$this->listTemplate}', + infowindowTemplatePath: '{$this->windowTemplate}', + originMarker: true, + visibleMarkersList: false, + storeLimit: -1, + maxDistance: true, + slideMap: false, + distanceAlert: -1, + {$kilometer}, + {$modal}, + mapID: 'map', + locationList: 'loc-list', + mapSettings: { + zoom: 0, + mapTypeId: google.maps.MapTypeId.ROADMAP, + disableDoubleClickZoom: false, + scrollwheel: true, + navigationControl: false, + draggable: true + } + }) + });", + "locator_map_init_script"); +} +``` + +Please note that this will replace the script that is loaded. +More options for the javascript map options can be found [here](https://github.com/bjorn2404/jQuery-Store-Locator-Plugin). \ No newline at end of file diff --git a/docs/en/index.md b/docs/en/index.md index a57608e..dbeb482 100644 --- a/docs/en/index.md +++ b/docs/en/index.md @@ -4,4 +4,6 @@ See [User Guide](userguide/index.md) for information on using the Locator module in the CMS. -See [Importing Locations](userguide/import.md) for information on importing Location and Category records. \ No newline at end of file +See [Importing Locations](userguide/import.md) for information on importing Location and Category records. + +See [Extending](code/index.md) for information on how to extend some functionality. \ No newline at end of file From 57b1ecbbe76621e8cfd5d3cbdb58b8a00b740e2b Mon Sep 17 00:00:00 2001 From: mak001 Date: Tue, 25 Jul 2017 13:15:47 -0500 Subject: [PATCH 2/3] Updated documentation for custom javascript --- docs/en/code/index.md | 70 +++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/docs/en/code/index.md b/docs/en/code/index.md index 935a14c..b9d6837 100644 --- a/docs/en/code/index.md +++ b/docs/en/code/index.md @@ -4,39 +4,45 @@ To change how the front-end javascript displays the map the custom script with t This example shows how to reference custom templates and a custom data location. It is recommended to copy the custom script from the [Locator Controller](../../../code/pages/Locator.php#L273-L298) and modify it. ```php -$load = 'autoGeocode: false, - fullMapStart: true,'; -$kilometer = ($this->owner->data()->Unit == 'km') ? "lengthUnit: 'km'" : "lengthUnit: 'm'"; -$modal = ($this->owner->data()->ModalWindow) ? 'modalWindow: true' : 'modalWindow: false'; +class Locator_ControllerExtension extends DataExtension +{ -Requirements::customScript(" - $(function(){ - $('#map-container').storeLocator({ - {$load} - dataLocation: '{$this->owner->Link()}SimpleXML.xml', - listTemplatePath: '{$this->listTemplate}', - infowindowTemplatePath: '{$this->windowTemplate}', - originMarker: true, - visibleMarkersList: false, - storeLimit: -1, - maxDistance: true, - slideMap: false, - distanceAlert: -1, - {$kilometer}, - {$modal}, - mapID: 'map', - locationList: 'loc-list', - mapSettings: { - zoom: 0, - mapTypeId: google.maps.MapTypeId.ROADMAP, - disableDoubleClickZoom: false, - scrollwheel: true, - navigationControl: false, - draggable: true - } - }) - });", - "locator_map_init_script"); + public function onAfterInit() + { + $load = 'autoGeocode: false, + fullMapStart: true,'; + $kilometer = ($this->owner->data()->Unit == 'km') ? "lengthUnit: 'km'" : "lengthUnit: 'm'"; + $modal = ($this->owner->data()->ModalWindow) ? 'modalWindow: true' : 'modalWindow: false'; + + Requirements::customScript(" + $(function(){ + $('#map-container').storeLocator({ + {$load} + dataLocation: '{$this->owner->Link()}SimpleXML.xml', + listTemplatePath: '{$this->owner->listTemplate}', + infowindowTemplatePath: '{$this->owner->windowTemplate}', + originMarker: true, + visibleMarkersList: false, + storeLimit: -1, + maxDistance: true, + slideMap: false, + distanceAlert: -1, + {$kilometer}, + {$modal}, + mapID: 'map', + locationList: 'loc-list', + mapSettings: { + zoom: 0, + mapTypeId: google.maps.MapTypeId.ROADMAP, + disableDoubleClickZoom: false, + scrollwheel: true, + navigationControl: false, + draggable: true + } + }) + });", + "locator_map_init_script"); + } } ``` From 86614e2f3f4408c20ba8d5a09f53a6f5658abc53 Mon Sep 17 00:00:00 2001 From: mak001 Date: Tue, 25 Jul 2017 15:58:15 -0500 Subject: [PATCH 3/3] updated extension example --- docs/en/code/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/en/code/index.md b/docs/en/code/index.md index b9d6837..ac0a783 100644 --- a/docs/en/code/index.md +++ b/docs/en/code/index.md @@ -4,7 +4,7 @@ To change how the front-end javascript displays the map the custom script with t This example shows how to reference custom templates and a custom data location. It is recommended to copy the custom script from the [Locator Controller](../../../code/pages/Locator.php#L273-L298) and modify it. ```php -class Locator_ControllerExtension extends DataExtension +class Locator_ControllerExtension extends Extension { public function onAfterInit() @@ -47,4 +47,4 @@ class Locator_ControllerExtension extends DataExtension ``` Please note that this will replace the script that is loaded. -More options for the javascript map options can be found [here](https://github.com/bjorn2404/jQuery-Store-Locator-Plugin). \ No newline at end of file +More options for the javascript map options can be found [here](https://github.com/bjorn2404/jQuery-Store-Locator-Plugin).