Event object

Properties

  • id #
    • The event's unique ID, which is also the element ID.
  • slug #
    • The event's unique URL slug.
  • title #
    • The event's title.
  • status #
    • The event's status.
  • enabled #
    • If the event is enabled.
  • authorId #
    • The event's author ID.
  • author #
    • The event's author.
  • startDate #
    • a Date object.
    • Format with .format("l, F j, Y \\a\\t g:ia")
      • |date("F j, Y") filter will not work because we use a different DateTime class, since Craft's DateTime class forces timezone changes and prevents us from working with UTC dates.
  • endDate #
    • a Date object.
    • Format with .format("l, F j, Y \\a\\t g:ia")
      • |date("F j, Y") filter will not work because we use a different DateTime class, since Craft's DateTime class forces timezone changes and prevents us from working with UTC dates.
  • duration #
  • allDay #
    • a boolean value.
  • multiDay #
    • a boolean value.
  • repeating #
    • a boolean value.
  • rrule #
    • The RFC RRule string used by ICS.
  • readableRepeatRule #
    • a human readable string of the rrule.
  • simplifiedRepeatRule #
    • a simplified version of the repeat rule (e.g. Weekly).
  • isCurrentlyHappening #
    • Checks if the user's current time is between the event's start and end date.
    • Based on the logged in user's locale, or otherwise the site's default timezone.
  • isHappeningOn #
    • Checks if the specified date and time is between the event's start and end date.
    • Ex: {% if event.isHappeningOn('2017-03-07 4:30pm') %} Yes! {% endif %}
      • Time has a default of 00:00:00, so if not specified, only All Day events will evaluate to true.
  • calendar #
  • exceptions #
    • a list of exception dates for recurring objects.
  • occurrences #
  • occurrenceCount #
    • the total number of occurrence results.
  • url #
    • the URL of the event, if available, generated from Event URL path setting for calendars.

You can also access any custom fields which you have added to events by directly calling their handle (the handle must not match any of the existing event properties).

Usage in Templates

If you had a field called Event Description with a handle of eventDescription you would access it in the template like this:

{{ event.eventDescription }}
1

You could make sure such a property exists first, to prevent errors in case the field is deleted:

{% if event.eventDescription is defined %}
  {{ event.eventDescription }}
{% endif %}
1
2
3
Last Updated: 1/14/2019, 4:12:52 PM