diff --git a/contao/dca/tl_module.php b/contao/dca/tl_module.php index e5b05cc..44a1509 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,mapEventColor,mapOrganizationColor,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,organizationTypeTags,mapShowExternalOrganizations,mapShowEvents,mapInitialDisplay,mapEventColor,mapOrganizationColor,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'; @@ -161,7 +161,9 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['eventListDomId'] = [ ]; $GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'mapCenterMode'; +$GLOBALS['TL_DCA']['tl_module']['palettes']['__selector__'][] = 'mapInitialDisplay'; $GLOBALS['TL_DCA']['tl_module']['subpalettes']['mapCenterMode_custom'] = 'mapCenterLat,mapCenterLng,mapCenterZoom'; +$GLOBALS['TL_DCA']['tl_module']['subpalettes']['mapInitialDisplay_organization_tag'] = 'mapInitialOrganizationTagId'; $GLOBALS['TL_DCA']['tl_module']['fields']['mapShowOrganizations'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_module']['mapShowOrganizations'], @@ -187,6 +189,38 @@ $GLOBALS['TL_DCA']['tl_module']['fields']['mapShowEvents'] = [ 'sql' => ['type' => 'string', 'length' => 1, 'fixed' => true, 'default' => ''], ]; +$GLOBALS['TL_DCA']['tl_module']['fields']['mapInitialDisplay'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_module']['mapInitialDisplay'], + 'exclude' => true, + 'inputType' => 'select', + 'options' => ['random', 'events', 'organization_tag'], + 'reference' => &$GLOBALS['TL_LANG']['tl_module']['mapInitialDisplay_options'], + 'eval' => ['mandatory' => true, 'submitOnChange' => true, 'tl_class' => 'w50', 'includeBlankOption' => false], + 'sql' => ['type' => 'string', 'length' => 32, 'default' => 'random'], +]; + +$GLOBALS['TL_DCA']['tl_module']['fields']['mapInitialOrganizationTagId'] = [ + 'label' => &$GLOBALS['TL_LANG']['tl_module']['mapInitialOrganizationTagId'], + 'exclude' => true, + 'inputType' => 'select', + 'options_callback' => static function (): array { + $rows = Database::getInstance() + ->prepare('SELECT DISTINCT t.id, t.tag FROM tl_tags t LEFT JOIN tl_tags_rel r ON r.tag_id=t.id AND r.ptable=? AND r.field=? ORDER BY t.tag ASC') + ->execute('tl_organization', 'tags') + ->fetchAllAssoc(); + + $options = []; + + foreach ($rows as $row) { + $options[(int) $row['id']] = (string) $row['tag']; + } + + return $options; + }, + 'eval' => ['includeBlankOption' => true, 'chosen' => true, 'tl_class' => 'w50'], + 'sql' => ['type' => 'integer', 'unsigned' => true, 'default' => 0], +]; + $GLOBALS['TL_DCA']['tl_module']['fields']['mapEventColor'] = [ 'label' => &$GLOBALS['TL_LANG']['tl_module']['mapEventColor'], 'exclude' => true, diff --git a/contao/languages/de/tl_module.php b/contao/languages/de/tl_module.php index 17729e3..385e12a 100644 --- a/contao/languages/de/tl_module.php +++ b/contao/languages/de/tl_module.php @@ -16,6 +16,13 @@ $GLOBALS['TL_LANG']['tl_module']['eventTypeTags'] = ['Anzuzeigende Veranstaltung $GLOBALS['TL_LANG']['tl_module']['mapShowOrganizations'] = ['Organisationen anzeigen', 'Wenn aktiviert, werden Organisations-Marker auf der Karte dargestellt.']; $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.']; +$GLOBALS['TL_LANG']['tl_module']['mapInitialDisplay_options'] = [ + 'random' => 'Zufällig', + 'events' => 'Veranstaltungen', + 'organization_tag' => 'Organisation mit Tag', +]; +$GLOBALS['TL_LANG']['tl_module']['mapInitialOrganizationTagId'] = ['Initialer Organisationstag', 'Wählen Sie den Tag, der initial angezeigt werden soll (nur bei „Organisation mit Tag“).']; $GLOBALS['TL_LANG']['tl_module']['mapEventColor'] = ['Event-Farbe (Kreise/Linien)', 'Farbe für Event-Cluster, Event-Punkte und Spiderfy-Verbindungslinien (Hex, z. B. #BC5067).']; $GLOBALS['TL_LANG']['tl_module']['mapOrganizationColor'] = ['Organisationsfarbe', 'Einheitliche Farbe für alle Organisations-Marker (Hex, z. B. #BC5067).']; $GLOBALS['TL_LANG']['tl_module']['mapCenterMode'] = ['Karten-Zentrierung', 'Wählen Sie, ob die Karte anhand der Marker oder mit festen Koordinaten zentriert werden soll.']; diff --git a/contao/languages/en/tl_module.php b/contao/languages/en/tl_module.php index cfdb33e..740cf87 100644 --- a/contao/languages/en/tl_module.php +++ b/contao/languages/en/tl_module.php @@ -16,6 +16,13 @@ $GLOBALS['TL_LANG']['tl_module']['eventTypeTags'] = ['Displayed event types', 'O $GLOBALS['TL_LANG']['tl_module']['mapShowOrganizations'] = ['Show organizations', 'If enabled, organization markers are rendered on the map.']; $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.']; +$GLOBALS['TL_LANG']['tl_module']['mapInitialDisplay_options'] = [ + 'random' => 'Random', + 'events' => 'Events', + 'organization_tag' => 'Organization with tag', +]; +$GLOBALS['TL_LANG']['tl_module']['mapInitialOrganizationTagId'] = ['Initial organization tag', 'Select the tag to be initially shown (only for "Organization with tag").']; $GLOBALS['TL_LANG']['tl_module']['mapEventColor'] = ['Event color (circles/lines)', 'Color for event clusters, event points and spiderfy connector lines (hex, e.g. #BC5067).']; $GLOBALS['TL_LANG']['tl_module']['mapOrganizationColor'] = ['Organization color', 'Unified color for all organization markers (hex, e.g. #BC5067).']; $GLOBALS['TL_LANG']['tl_module']['mapCenterMode'] = ['Map centering', 'Choose whether the map should center by markers or fixed coordinates.']; diff --git a/contao/templates/frontend/event_map.html.twig b/contao/templates/frontend/event_map.html.twig index e426462..8608892 100644 --- a/contao/templates/frontend/event_map.html.twig +++ b/contao/templates/frontend/event_map.html.twig @@ -1,4 +1,9 @@ {% set tags = mapOrganizationTags|default([]) %} +{% set showOrganizations = mapShowOrganizations|default(false) %} +{% set showEvents = mapShowEvents|default(false) %} +{% set showTagButtons = showOrganizations and tags is iterable and tags|length > 0 %} +{% set showEventButton = showOrganizations and showEvents %} +{% set showFilterButtons = showTagButtons or showEventButton %}
- + {% if showFilterButtons %} + + {% endif %}
- - - {% if tags is iterable and tags|length > 0 %} + {% if showTagButtons %} {% for tag in tags %} {% endfor %} {% endif %} - + {% if showEventButton %} + + {% endif %}