Skip to content

Instantly share code, notes, and snippets.

@pixeldeluxe
Forked from frontendbeast/gist:7188558
Created March 5, 2016 13:53
Show Gist options
  • Save pixeldeluxe/120e96c5e995a5491b54 to your computer and use it in GitHub Desktop.
Save pixeldeluxe/120e96c5e995a5491b54 to your computer and use it in GitHub Desktop.
Craft CMS future events listings, sorted by date and grouped by month and year. Requires Danny Nimmo's SortByField plugin. https://github.com/dannynimmo/craftcms-sortbyfield
{% set allEvents = craft.entries.section('events').find() %}
{% set futureEvents = [] %}
{% for event in allEvents %}
{% if event.startDate | date('U') >= 'now' | date('U') %}
{% set futureEvents = futureEvents | merge([event]) %}
{% endif %}
{% endfor %}
{% for date, events in futureEvents | sortByField('startDate') | group('startDate|date("F Y")') %}
<h1>{{ date }}</h1>
<ul>
{% for event in events %}
<li>{{ event.title }}</li>
{% endfor %}
</ul>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment