Skip to content

Instantly share code, notes, and snippets.

@niallthompson
Last active July 8, 2016 10:48
Show Gist options
  • Save niallthompson/af1dd27d5db1ba23cf74 to your computer and use it in GitHub Desktop.
Save niallthompson/af1dd27d5db1ba23cf74 to your computer and use it in GitHub Desktop.
Craft Calendars
<h1>Upcoming {{ "Events"|t }}</h1>
{% set upcomingparams = {
calendar: 'projectEvents',
dateRangeStart: 'today',
dateRangeEnd: 'next year'
} %}
{% for e in craft.calendars.eventData(upcomingparams).events %}
<article class="">
<hr class="rule rule--dashed">
<h2>{{ e.element.title }}</h2>
<h5 class="subtitle">{{ e.startDate | date("d M Y") }}</h5>
<h5 class="subtitle">{{ e.element.subtitle }}</h5>
<div class="google-maps-strip">
{% for marker in e.element.eventMap.getMarkers() %}
{% set options = {
id: 'map',
width: '100%',
height: '100px',
options: {
maxZoom: 15,
minZoom: 5
}
} %}
{{ craft.googleMaps.map(options) }}
{{ craft.googleMaps.data('map', e.element.eventMap) }}
{% endfor %}
</div>
<a href="{{ e.element.url }}" class="margin-top button button--ujarak button--border-thin button--text-thick">{{ "More" | translate }}</a><br>
</article>
{% endfor %}
<hr class="rule rule--thin margin-top">
<h1>Past {{ "Events"|t }}</h1>
{% set pastparams = {
calendar: 'projectEvents',
dateRangeStart: '2013',
dateRangeEnd: 'yesterday'
} %}
{% for p in craft.calendars.eventData(pastparams).events %}
<article class="">
<hr class="rule rule--dashed">
<h2>{{ p.element.title }}</h2>
<h5 class="subtitle">{{ p.startDate | date("d M Y") }}</h5>
<h5 class="subtitle">{{ p.element.subtitle }}</h5>
<div class="google-maps-strip">
{% for marker in p.element.eventMap.getMarkers() %}
{% set options = {
id: 'map',
width: '100%',
height: '100px',
options: {
maxZoom: 15,
minZoom: 5
}
} %}
{{ craft.googleMaps.map(options) }}
{{ craft.googleMaps.data('map', p.element.eventMap) }}
{% endfor %}
</div>
<a href="{{ p.element.url }}">{{ "More" | translate }}</a><br>
</article>
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment