This document is for an older version of
Calendar
. View latest version →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 differentDateTime
class, since Craft'sDateTime
class forces timezone changes and prevents us from working withUTC
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 differentDateTime
class, since Craft'sDateTime
class forces timezone changes and prevents us from working withUTC
dates.
duration
#allDay
#- a
boolean
value.
- a
multiDay
#- a
boolean
value.
- a
repeating
#- a
boolean
value.
- a
rrule
#- The RFC RRule string used by ICS.
readableRepeatRule
#- a human readable string of the
rrule
.
- a human readable string of the
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 totrue
.
- Time has a default of
calendar
#exceptions
#- a list of exception dates for recurring objects.
occurrences
#- a list of Event objects of all occurrences for repeating rules.
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
2
3