diff --git a/contao/dca/tl_module.php b/contao/dca/tl_module.php index 76d07ef..ff403f1 100644 --- a/contao/dca/tl_module.php +++ b/contao/dca/tl_module.php @@ -9,7 +9,7 @@ use Contao\StringUtil; $GLOBALS['TL_DCA']['tl_module']['palettes']['member_organizations'] = '{title_legend},name,headline,type;{eventmanager_legend},editPage;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['palettes']['member_events'] = '{title_legend},name,headline,type;{eventmanager_legend},editPage;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['palettes']['event_filter'] = '{title_legend},name,headline,type;{eventmanager_legend},cal_calendar,eventListDomId;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; -$GLOBALS['TL_DCA']['tl_module']['palettes']['eventmanager_map'] = '{title_legend},name,headline,type;{eventmanager_legend},mapShowOrganizations,organizationTypeTags,mapShowExternalOrganizations,mapShowEvents,mapInitialDisplay,mapEventColor,mapOrganizationColor,mapPitch,mapCenterMode;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; +$GLOBALS['TL_DCA']['tl_module']['palettes']['eventmanager_map'] = '{title_legend},name,headline,type;{eventmanager_legend},mapShowOrganizations,mapOrganizationListPage,organizationTypeTags,mapShowExternalOrganizations,mapShowEvents,mapInitialDisplay,mapEventColor,mapOrganizationColor,mapPitch,mapCenterMode;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['palettes']['organization_edit'] = '{title_legend},name,headline,type;{eventmanager_legend},listPage,logoFolder,organizationTypeTags;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; $GLOBALS['TL_DCA']['tl_module']['palettes']['event_edit'] = '{title_legend},name,headline,type;{eventmanager_legend},listPage,eventFolder,termsPage,frontendAuthorId,frontendArchiveId,eventTypeTags;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID'; @@ -191,6 +191,14 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['mapShowOrganizations'] = [ 'sql' => ['type' => 'string', 'length' => 1, 'fixed' => true, 'default' => ''], ]; +$GLOBALS['TL_DCA']['tl_module']['fields']['mapOrganizationListPage'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_module']['mapOrganizationListPage'], + 'exclude' => true, + 'inputType' => 'pageTree', + 'eval' => ['fieldType' => 'radio', 'mandatory' => false, 'tl_class' => 'w50'], + 'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0], +]; + $GLOBALS['TL_DCA']['tl_module']['fields']['mapShowExternalOrganizations'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_module']['mapShowExternalOrganizations'], 'exclude' => true, diff --git a/contao/languages/de/tl_module.php b/contao/languages/de/tl_module.php index 117f140..e4696d3 100644 --- a/contao/languages/de/tl_module.php +++ b/contao/languages/de/tl_module.php @@ -14,6 +14,7 @@ $GLOBALS['TL_LANG']['tl_module']['eventListDomId'] = ['Eventlisten-ID (DOM)', 'W $GLOBALS['TL_LANG']['tl_module']['organizationTypeTags'] = ['Anzuzeigende Organisationstypen', 'Optional: Begrenzen Sie die im Frontend anzeigbaren Organisationstyp-Tags. Leer = alle.']; $GLOBALS['TL_LANG']['tl_module']['eventTypeTags'] = ['Anzuzeigende Veranstaltungstypen', 'Optional: Begrenzen Sie die im Frontend anzeigbaren Veranstaltungstyp-Tags. Leer = alle.']; $GLOBALS['TL_LANG']['tl_module']['mapShowOrganizations'] = ['Organisationen anzeigen', 'Wenn aktiviert, werden Organisations-Marker auf der Karte dargestellt.']; +$GLOBALS['TL_LANG']['tl_module']['mapOrganizationListPage'] = ['Seite für Organisationsliste', 'Optional: Seite, auf der die Organisationsliste liegt. Wird für den Link „mehr Infos“ im Organisations-Popup verwendet.']; $GLOBALS['TL_LANG']['tl_module']['mapShowExternalOrganizations'] = ['Externe Organisationen anzeigen', 'Wenn aktiviert, werden externe Organisationen (isExternal=1) zusätzlich auf der Karte dargestellt. Standard: nein.']; $GLOBALS['TL_LANG']['tl_module']['mapShowEvents'] = ['Veranstaltungen anzeigen', 'Wenn aktiviert, werden Event- (inkl. Orts-) Marker auf der Karte dargestellt.']; $GLOBALS['TL_LANG']['tl_module']['mapInitialDisplay'] = ['Initiale Anzeige', 'Definiert, welche Marker beim Laden der Karte initial angezeigt werden.']; diff --git a/contao/languages/en/tl_module.php b/contao/languages/en/tl_module.php index 3f10262..e02f0cf 100644 --- a/contao/languages/en/tl_module.php +++ b/contao/languages/en/tl_module.php @@ -14,6 +14,7 @@ $GLOBALS['TL_LANG']['tl_module']['eventListDomId'] = ['Event list ID (DOM)', 'Se $GLOBALS['TL_LANG']['tl_module']['organizationTypeTags'] = ['Displayed organization types', 'Optional: Limit which organization type tags can be selected in the frontend. Empty = all.']; $GLOBALS['TL_LANG']['tl_module']['eventTypeTags'] = ['Displayed event types', 'Optional: Limit which event type tags can be selected in the frontend. Empty = all.']; $GLOBALS['TL_LANG']['tl_module']['mapShowOrganizations'] = ['Show organizations', 'If enabled, organization markers are rendered on the map.']; +$GLOBALS['TL_LANG']['tl_module']['mapOrganizationListPage'] = ['Organization list page', 'Optional: page containing the organization list. Used for the "more info" link in organization popups.']; $GLOBALS['TL_LANG']['tl_module']['mapShowExternalOrganizations'] = ['Show external organizations', 'If enabled, external organizations (isExternal=1) are additionally rendered on the map. Default: no.']; $GLOBALS['TL_LANG']['tl_module']['mapShowEvents'] = ['Show events', 'If enabled, event markers (including related locations) are rendered on the map.']; $GLOBALS['TL_LANG']['tl_module']['mapInitialDisplay'] = ['Initial display', 'Defines which markers are initially shown when the map is loaded.']; diff --git a/contao/templates/frontend/event_map.html.twig b/contao/templates/frontend/event_map.html.twig index 4b182bb..1954168 100644 --- a/contao/templates/frontend/event_map.html.twig +++ b/contao/templates/frontend/event_map.html.twig @@ -105,7 +105,11 @@ width: 100%; min-height: 420px; } + + .maplibregl-popup { + z-index: 2147483647; + } - + diff --git a/public/assets/map-module.js b/public/assets/map-module.js index 5c0028f..dfa8151 100644 --- a/public/assets/map-module.js +++ b/public/assets/map-module.js @@ -438,6 +438,20 @@ const popupHtmlFor = (item) => { ].join(''); } + if (item.type === 'organisation') { + const title = sanitizeDisplayText(item.title || ''); + const detailUrl = String(item.extra?.detailUrl || '').trim(); + const hasDetailUrl = /^(https?:\/\/|\/)/i.test(detailUrl); + const detailLink = hasDetailUrl + ? `
` + : ''; + + return [ + `${title}`, + detailLink, + ].join(''); + } + return `${sanitizeDisplayText(item.title)}`; }; diff --git a/src/Controller/Frontend/EventMapController.php b/src/Controller/Frontend/EventMapController.php index d133a8b..5da0c9f 100644 --- a/src/Controller/Frontend/EventMapController.php +++ b/src/Controller/Frontend/EventMapController.php @@ -8,6 +8,7 @@ use Contao\CoreBundle\Controller\FrontendModule\AbstractFrontendModuleController use Contao\CoreBundle\DependencyInjection\Attribute\AsFrontendModule; use Contao\CoreBundle\Twig\FragmentTemplate; use Contao\ModuleModel; +use Contao\PageModel; use Contao\StringUtil; use MummertMedia\EventManagerBundle\Service\MapModuleDataProvider; use Symfony\Component\HttpFoundation\Request; @@ -52,6 +53,8 @@ class EventMapController extends AbstractFrontendModuleController $selectedOrganizationTagIds = [] === $selectedOrganizationTagIds ? [] : array_values(array_intersect($selectedOrganizationTagIds, $availableOrganizationTagIds)); + $organizationListPageId = (int) ($model->mapOrganizationListPage ?? 0); + $organizationListBaseUrl = $this->buildOrganizationListBaseUrl($organizationListPageId, $request); $initialDisplay = (string) ($model->mapInitialDisplay ?? self::DEFAULT_INITIAL_DISPLAY); $initialOrganizationTagId = (int) ($model->mapInitialOrganizationTagId ?? 0); $centerMode = (string) ($model->mapCenterMode ?? self::DEFAULT_CENTER_MODE); @@ -88,7 +91,7 @@ class EventMapController extends AbstractFrontendModuleController $template->set('mapCenterZoom', (int) ($model->mapCenterZoom ?? 12)); $template->set('mapPitch', $mapPitch); $template->set('mapItemsJson', json_encode( - $this->mapModuleDataProvider->getMapItems($showOrganizations, $showEvents, $showExternalOrganizations, $selectedOrganizationTagIds), + $this->mapModuleDataProvider->getMapItems($showOrganizations, $showEvents, $showExternalOrganizations, $selectedOrganizationTagIds, $organizationListBaseUrl), \JSON_HEX_TAG | \JSON_HEX_AMP | \JSON_HEX_APOS | \JSON_HEX_QUOT | \JSON_UNESCAPED_UNICODE | \JSON_THROW_ON_ERROR, )); $template->set('mapOrganizationTags', $this->mapModuleDataProvider->getOrganizationTags($selectedOrganizationTagIds)); @@ -147,4 +150,29 @@ class EventMapController extends AbstractFrontendModuleController return $parsedPitch; } + + private function buildOrganizationListBaseUrl(int $pageId, Request $request): string + { + if ($pageId <= 0) { + return ''; + } + + $pageModel = PageModel::findById($pageId); + + if (null === $pageModel) { + return ''; + } + + $frontendUrl = trim((string) $pageModel->getFrontendUrl()); + + if ('' === $frontendUrl) { + return ''; + } + + if (preg_match('#^https?://#i', $frontendUrl)) { + return $frontendUrl; + } + + return rtrim($request->getSchemeAndHttpHost(), '/').'/'.ltrim($frontendUrl, '/'); + } } diff --git a/src/Service/MapModuleDataProvider.php b/src/Service/MapModuleDataProvider.php index 5d1d77d..6d58e11 100644 --- a/src/Service/MapModuleDataProvider.php +++ b/src/Service/MapModuleDataProvider.php @@ -31,7 +31,7 @@ class MapModuleDataProvider /** * @return list