-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1895 from danskernesdigitalebibliotek/KBHBIB-47_d…
…ate-range Display datetime attribute in daterange fields. KBHBIB-47
- Loading branch information
Showing
2 changed files
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
web/themes/custom/novel/templates/fields/field--daterange.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |