Skip to content

Commit

Permalink
Merge pull request #1895 from danskernesdigitalebibliotek/KBHBIB-47_d…
Browse files Browse the repository at this point in the history
…ate-range

Display datetime attribute in daterange fields. KBHBIB-47
  • Loading branch information
rasben authored Jan 2, 2025
2 parents 8cf6e27 + 1f1c39d commit 7241321
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
{% endif %}
{% if content_type and date %}|{% endif %}
{% if date %}
<time class="hero__details__date">{{ date }}</time>
<div class="hero__details__date">{{ date }}</div>
{% endif %}
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% for i, item in items %}
{% set start_date = element['#items'][i].start_date %}
{% set end_date = element['#items'][i].end_date %}

{#
Creating a datetime attribute, if dates are available.
If both start and end date are available, we display the whole range,
seperated by a /.
#}
<time {% if start_date %}datetime="{{ start_date|date('Y-m-d H:i:sP') }}
{% if end_date %}/{{ end_date|date('Y-m-d H:i:sP') }}{% endif %}
"{% endif %}>

{{ item.content }}
</time>
{% endfor %}

0 comments on commit 7241321

Please sign in to comment.