TIP

WE'RE HIRING! 💼

The Solspace team is expanding! If you love Craft CMS and you’re looking for an exciting full-time remote position working on software development for the Freeform and Calendar plugins for Craft and more, we’d love to hear from you!

Check Out Job Listing!

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
Last Updated: 1/15/2020, 4:39:52 PM