I'm using a matrix inside a Super Table to organize events, and I'd like to order the events using the date field for each event.
I'm currently showing the first five events using limit
then using offset
to show the rest of the blocks after the first five. Then I'm separating future and past events using the date field. Like this:
First five upcoming events:
{% for block in block.eventList.limit(5) %}
{% if block.eventDate >= now %}
{{ block.eventTitle }}
{% endif %}
{% endfor %}
The rest of the upcoming events:
{% for block in block.eventList.offset(5) %}
{% if block.eventDate >= now %}
{{ block.eventTitle }}
{% endif %}
{% endfor %}
All past events:
{% for block in block.eventList %}
{% if block.eventDate <= now %}
{{ block.eventTitle }}
{% endif %}
{% endfor %}
This works fine as is, but it doesn't sort the events within the sections by the date field. How can I add that?