Skip to content

Instantly share code, notes, and snippets.

View pixeldeluxe's full-sized avatar

Martijn La Feber pixeldeluxe

View GitHub Profile
@pixeldeluxe
pixeldeluxe / gist:120e96c5e995a5491b54
Created March 5, 2016 13:53 — forked from frontendbeast/gist:7188558
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")') %}