Last active
March 5, 2016 13:53
-
-
Save frontendbeast/7188558 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
This file contains hidden or 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
{% 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