diff --git a/module/dca/tl_content.php b/module/dca/tl_content.php index 56d7def..ddf8d6c 100644 --- a/module/dca/tl_content.php +++ b/module/dca/tl_content.php @@ -11,7 +11,7 @@ $GLOBALS['TL_DCA']['tl_content']['metapalettes']['leaflet'] = array( 'type' => array('type', 'headline'), - 'leaflet' => array('leaflet_map', 'leaflet_width', 'leaflet_height'), + 'leaflet' => array('leaflet_map', 'leaflet_mapId', 'leaflet_width', 'leaflet_height', 'leaflet_template'), 'templates' => array(':hide', 'customTpl'), 'protected' => array(':hide', 'protected'), 'expert' => array(':hide', 'guests', 'cssID', 'space'), @@ -33,6 +33,18 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_map'] = array( 'sql' => "int(10) unsigned NOT NULL default '0'" ); +$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_mapId'] = array( + 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_mapId'], + 'inputType' => 'text', + 'exclude' => true, + 'eval' => array( + 'tl_class' => 'w50', + 'chosen' => true, + 'maxlength' => 16, + ), + 'sql' => "varchar(16) NOT NULL default ''" +); + $GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_width'] = array( 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_width'], 'inputType' => 'inputUnit', @@ -53,3 +65,15 @@ $GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_height'] = array( 'eval' => array('rgxp' => 'digit', 'tl_class' => 'w50'), 'sql' => "varchar(64) NOT NULL default ''" ); + +$GLOBALS['TL_DCA']['tl_content']['fields']['leaflet_template'] = array( + 'label' => &$GLOBALS['TL_LANG']['tl_content']['leaflet_template'], + 'inputType' => 'select', + 'exclude' => true, + 'options_callback' => \Netzmacht\Contao\Toolkit\Dca::createGetTemplatesCallback('leaflet_map_js'), + 'eval' => array( + 'tl_class' => 'w50', + 'chosen' => true, + ), + 'sql' => "varchar(64) NOT NULL default ''" +); diff --git a/module/dca/tl_module.php b/module/dca/tl_module.php index b8480af..3b64b03 100644 --- a/module/dca/tl_module.php +++ b/module/dca/tl_module.php @@ -11,7 +11,7 @@ $GLOBALS['TL_DCA']['tl_module']['metapalettes']['leaflet'] = array( 'type' => array('name', 'type', 'headline'), - 'leaflet' => array('leaflet_map', 'leaflet_width', 'leaflet_height'), + 'leaflet' => array('leaflet_map', 'leaflet_mapId', 'leaflet_width', 'leaflet_height', 'leaflet_template'), 'templates' => array(':hide', 'customTpl'), 'protected' => array(':hide', 'protected'), 'expert' => array(':hide', 'guests', 'cssID', 'space'), @@ -33,6 +33,18 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_map'] = array( 'sql' => "int(10) unsigned NOT NULL default '0'" ); +$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_mapId'] = array( + 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_mapId'], + 'inputType' => 'text', + 'exclude' => true, + 'eval' => array( + 'tl_class' => 'w50', + 'chosen' => true, + 'maxlength' => 16, + ), + 'sql' => "varchar(16) NOT NULL default ''" +); + $GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_width'] = array( 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_width'], 'inputType' => 'inputUnit', @@ -53,3 +65,15 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_height'] = array( 'eval' => array('rgxp' => 'digit', 'tl_class' => 'w50'), 'sql' => "varchar(64) NOT NULL default ''" ); + +$GLOBALS['TL_DCA']['tl_module']['fields']['leaflet_template'] = array( + 'label' => &$GLOBALS['TL_LANG']['tl_module']['leaflet_template'], + 'inputType' => 'select', + 'exclude' => true, + 'options_callback' => \Netzmacht\Contao\Toolkit\Dca::createGetTemplatesCallback('leaflet_map_js'), + 'eval' => array( + 'tl_class' => 'w50', + 'chosen' => true, + ), + 'sql' => "varchar(64) NOT NULL default ''" +); diff --git a/module/languages/en/modules.php b/module/languages/en/modules.php index b680f9a..178e11a 100644 --- a/module/languages/en/modules.php +++ b/module/languages/en/modules.php @@ -14,3 +14,9 @@ $GLOBALS['TL_LANG']['MOD']['tl_leaflet_layer'] = 'Layers'; $GLOBALS['TL_LANG']['MOD']['tl_leaflet_icon'] = 'Icons'; $GLOBALS['TL_LANG']['MOD']['tl_leaflet_marker'] = 'Markers'; $GLOBALS['TL_LANG']['MOD']['tl_leaflet_control'] = 'Controls'; + +$GLOBALS['TL_LANG']['FMD']['leaflet'][0] = 'Leaflet Map'; +$GLOBALS['TL_LANG']['FMD']['leaflet'][1] = 'Integrate leaflet map as frontend module.'; + +$GLOBALS['TL_LANG']['CTE']['leaflet'][0] = 'Leaflet Map'; +$GLOBALS['TL_LANG']['CTE']['leaflet'][1] = 'Integrate leaflet map as content element.'; diff --git a/module/languages/en/tl_content.php b/module/languages/en/tl_content.php new file mode 100644 index 0000000..8c52a55 --- /dev/null +++ b/module/languages/en/tl_content.php @@ -0,0 +1,12 @@ +mapService->handleAjaxRequest('map_' . $this->getIdentifier()); + $this->mapService->handleAjaxRequest($this->getIdentifier()); if (TL_MODE === 'BE') { $model = MapModel::findByPK($this->leaflet_map); @@ -101,8 +101,9 @@ trait HybridTrait protected function compile() { try { - $mapId = 'map_' . $this->getIdentifier(); - $map = $this->mapService->generate($this->leaflet_map, null, $mapId); + $template = $this->leaflet_template ?: 'leaflet_map_js'; + $mapId = $this->getIdentifier(); + $map = $this->mapService->generate($this->leaflet_map, null, $mapId, $template); $GLOBALS['TL_BODY'][] = ''; diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php b/src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php index 638ccec..826cbc2 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php +++ b/src/Netzmacht/Contao/Leaflet/Frontend/MapElement.php @@ -47,6 +47,14 @@ class MapElement extends \ContentElement */ protected function getIdentifier() { - return 'ce_' . $this->id; + if ($this->leaflet_mapId) { + return $this->leaflet_mapId; + } + + if ($this->cssID[0]) { + return 'map_' . $this->cssID[0]; + } + + return 'map_ce_' . $this->id; } } diff --git a/src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php b/src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php index 7b09da0..1e376ee 100644 --- a/src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php +++ b/src/Netzmacht/Contao/Leaflet/Frontend/MapModule.php @@ -46,6 +46,14 @@ class MapModule extends \Module */ protected function getIdentifier() { - return 'mod_' . $this->id; + if ($this->leaflet_mapId) { + return $this->leaflet_mapId; + } + + if ($this->cssID[0]) { + return 'map_' . $this->cssID[0]; + } + + return 'map_mod_' . $this->id; } }