This document is for an older version of

Calendar

.

View latest version →

Templating

calendar.event function

The calendar.event template function fetches a single event by its unique ID or slug.

Parameters

First parameter is the ID or slug of the event, the second parameter is an object of optional parameter:

  • targetDate #
    • The recurrence date you'd like to specifically target. Accepts formats like 2019-01-20. You would typically pass date segments in the URI to achieve this. See example below...

Usage in Templates

{% set occurrenceDate = null %}
{% if craft.app.request.segment(3) and craft.app.request.segment(4) and craft.app.request.segment(5) %}
    {% set occurrenceDate = craft.app.request.segment(3)~"-"~craft.app.request.segment(4)~"-"~craft.app.request.segment(5) %}
{% endif %}

{% set event = craft.calendar.event(segment2, {targetDate: occurrenceDate}) %}

<ul>
{% if event %}
    <li>
        {{ event.title }} - {{ event.startDate.format("l d, Y") }}<br />
        {{ event.eventDescription }}
    </li>
{% endif %}
</ul>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15