Skip to content

Commit

Permalink
Merge pull request #1169 from City-of-Helsinki/UHF-X_curated_events_w…
Browse files Browse the repository at this point in the history
…hitescreen

UHF-X: External event entity causes WSOD fix
  • Loading branch information
teroelonen authored Jan 28, 2025
2 parents 0f27686 + 8f6754d commit aa5d861
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions templates/content/external-entity--linkedevents-event.html.twig
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
{% set is_multidate = start_timestamp|date('Y-m-d') != end_timestamp|date('Y-m-d') %}
{% set same_year = start_timestamp|date('Y') == end_timestamp|date('Y') %}
{% set html_start = start_timestamp|format_date('custom', 'Y-m-d') ~ 'T' ~ start_timestamp|format_date('custom', 'H:i') %}
{% set html_end = end_timestamp|format_date('custom', 'Y-m-d') ~ 'T' ~ end_timestamp|format_date('custom', 'H:i') %}

{% if is_multidate and not same_year %}
{% set card_start_timestamp = start_timestamp|date('d.m.Y')%}
{% set card_end_timestamp = end_timestamp|date('d.m.Y')%}
{% elseif is_multidate %}
{% set card_start_timestamp = start_timestamp|date('d.m.')%}
{% set card_end_timestamp = end_timestamp|date('d.m.Y')%}
{% else %}
{% set card_start_timestamp = start_timestamp|format_date('publication_date_format') %}
{% set card_end_timestamp = end_timestamp|format_date('custom', 'H:i') %}
{% if start_timestamp and end_timestamp is not null %}
{% set is_multidate = start_timestamp|date('Y-m-d') != end_timestamp|date('Y-m-d') %}
{% set same_year = start_timestamp|date('Y') == end_timestamp|date('Y') %}
{% set card_start_timestamp = is_multidate and not same_year
? start_timestamp|date('d.m.Y')
: is_multidate
? start_timestamp|date('d.m.')
: start_timestamp|format_date('publication_date_format') %}
{% set card_end_timestamp = is_multidate
? end_timestamp|date('d.m.Y')
: end_timestamp|format_date('custom', 'H:i') %}
{% set html_start = start_timestamp|format_date('custom', 'Y-m-d') ~ 'T' ~ start_timestamp|format_date('custom', 'H:i') %}
{% set html_end = end_timestamp|format_date('custom', 'Y-m-d') ~ 'T' ~ end_timestamp|format_date('custom', 'H:i') %}
{% endif %}


{% embed '@hdbt/component/card-teaser.twig' with {
card_image: content.main_image,
card_title: content.external_link[0]['#title'],
card_url: content.external_link[0]['#url'],
card_has_start_and_end: true,
card_start_timestamp: card_start_timestamp,
card_end_timestamp: card_end_timestamp,
card_html_start: html_start,
card_html_end: html_end,
card_has_start_and_end: start_timestamp and end_timestamp is not null,
card_start_timestamp: card_start_timestamp|default(null),
card_end_timestamp: card_end_timestamp|default(null),
card_html_start: html_start|default(null),
card_html_end: html_end|default(null),
} %}
{% endembed %}

0 comments on commit aa5d861

Please sign in to comment.