Skip to content

Instantly share code, notes, and snippets.

@dustinwalker
Created February 18, 2014 15:58
Show Gist options
  • Save dustinwalker/9073738 to your computer and use it in GitHub Desktop.
Save dustinwalker/9073738 to your computer and use it in GitHub Desktop.
List events in CraftCMS
{#
# SECTION_NAME is the name of the section for events
# allEvents, futureEvents, event can be anything
# Not sure where I got this sample from
#}
{% set allEvents = craft.entries.section('SECTION_NAME').limit(3).find() %}
{% set futureEvents = [] %}
{% for event in allEvents %}
{% if event.dateOfEvent | date('U') >= 'now' | date('U') %}
{% set futureEvents = futureEvents | merge([event]) %}
{% endif %}
{% endfor %}
{% for event in futureEvents | sort('event.dateOfEvent') %}
<li>
<h4>{{ event.title }}</h4>
</a>
</li>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment