I'm creating a line up listing page for a festival, across 4 nights. Acts are listed, per day, sorted by a date
field in order of a start time
field.
The issue I'm having is that midnight until 3am is still considered the night of an event but my time
field obviously considers it otherwise.
e.g. an act is performing on the Friday morning at 1am but I need to list this at the end of the Thursday acts.
So the user adds it to the CMS on the Thursday but it appears at the start of the day instead of the end.
Essentially, I just need any acts that appear between 00:00
and 03:00
at the top of a list e.g
Thursday
- Act 1 - 1am - 2am
- Act 2 - 12am - 1am
- Act 3 - 11pm - 12am
- Act 4 - 10pm - 11pm
etc
This is the code I have so far
whatDateAreTheyPerforming
is a date field
startTime
and endTime
are time fields
{% set entryIds = craft.entries.section('lineUp').ids() %}
{% set categories = craft.categories.relatedTo({ sourceElement: entryIds }).find() %}
{% for category in categories %}
{# Fetch all of the entries related to this category #}
{% set entries = craft.entries.relatedTo(category) %}
{# Group entries by date and order by start time #}
{% for date, entries in entries.order('whatDateAreTheyPerforming', 'time(startTime) desc')|
group('whatDateAreTheyPerforming') %}
<div>
<h3>DAY HERE - {{ date | date('l') }} <span>{{ date | date('jS') }}</span></h3>
<ul>
{% for entry in entries %}
<li>
<h4>{{ entry.title }}
<span>{{ entry.whatDateAreTheyPerforming | date('l') }} - {{ entry.startTime | date('G:i') }} - {{ entry.endTime | date('G:i') }}</span>
</h4>
</li>
{% endfor %}
</ul>
</div><!-- col -->
{% endfor %}
{% endfor %}
I hope this makes sense, any guidance will be appreciated.