mirror of
https://github.com/netzmacht/contao-leaflet-maps.git
synced 2025-12-02 13:03:43 +01:00
Support custom templates and map ids.
This commit is contained in:
@@ -66,7 +66,7 @@ trait HybridTrait
|
||||
*/
|
||||
public function generate()
|
||||
{
|
||||
$this->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'][] = '<script>' . $map .'</script>';
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user