Download raw (3.0 KB)
{% extends 'partials/base.html.twig' %} {% block content %} <h1>{{ page.title }}</h1> {{ page.content }} {% if config.plugins['simple-events'].use_regions %} {% for reg_id, reg in config.plugins['simple-events'].regions %} {% set events = page.collection | filterEvents(reg_id) %} {% if events.count > 0 %} <h2 id="{{ reg_id }}">{{ reg }}</h2> <ul class="events"> {% for event in events %} {% set config = attribute(event.header, 'simple-events') %} {% if config.end is defined and config.end != config.start %} {% set eventdate = config.start|date('M j') ~ ' – ' ~ config.end|date('M j, Y') %} {% else %} {% set eventdate = config.start|date('M j, Y') %} {% endif %} {% if config.link is defined %} {% set eventtext = linkit(event.title, config.link) %} {% else %} {% set eventtext = event.title %} {% endif %} <li><span class="eventdate">{{ eventdate }}</span>{{ eventtext }}</li> {% endfor %} </ul> {% endif %} {% endfor %} {% else %} <ul class="events"> {% set events = page.collection() %} {% for event in events %} {% set config = attribute(event.header, 'simple-events') %} {% if config.end is defined and config.end != config.start %} {% set eventdate = config.start|date('M j') ~ ' – ' ~ config.end|date('M j, Y') %} {% else %} {% set eventdate = config.start|date('M j, Y') %} {% endif %} {% if config.link is defined %} {% set eventtext = linkit(event.title, config.link) %} {% else %} {% set eventtext = event.title %} {% endif %} <li><span class="eventdate">{{ eventdate }}</span>{{ eventtext }}</li> {% endfor %} </ul> {% endif %} {% endblock %} {# ----- customise the date for another language: an example in German ----- #} {# put this in the for loop (for event in events), replacing the if clause above: {% if config.end is defined and config.end != config.start %} {% if config.end|date('j') == config.start|date('j') + 1 %} {% set month ="" %} {% if config.end|date('m') != config.start|date('m') %} {% set month = ' ' ~ 'GRAV.MONTHS_OF_THE_YEAR'|ta(config.start|date('n') -1) %} {% endif %} {% if config.end|date('j') == config.start|date('j') + 1 %} {% set eventdate = config.start|date('j.') ~ month ~ ' und ' ~ config.end|date('j. ') ~ 'GRAV.MONTHS_OF_THE_YEAR'|ta(config.end|date('n') -1) ~ ' ' ~ config.end|date('Y') %} {% else %} {% set eventdate = config.start|date('j.') ~ month ~ ' bis ' ~ config.end|date('j. ') ~ 'GRAV.MONTHS_OF_THE_YEAR'|ta(config.end|date('n') -1) ~ ' ' ~ config.end|date('Y') %} {% endif %} {% else %} {% set eventdate = config.start|date('j. ') ~ 'GRAV.MONTHS_OF_THE_YEAR'|ta(config.start|date('n') -1) ~ ' ' ~ config.start|date('Y') %} {% endif %} #}