Plain ICS for Craft CMS
A Craft CMS plugin that implements eluceo/iCal package for creating ICS files in your Twig templates.
The plugin includes a single Twig variable, render, which accepts an array/object of parameters to render the iCal event, and an optional boolean indicating whether to force-download and exit, or return the iCal contents.
Specifying the boolean allows you to use the results elsewhere in your Craft plugins, e.g.:
use \Craft\PlainIcsVariable as PlainIcsVariable;
$results = PlainIcsVariable::render($params, true);
- Title
title- String - Start Date Time
startDateTime- a properly formattedDateTimeobject in Craft. - End Date Time
endDateTime- a properly formattedDateTimeobject in Craft.- Descriptiondescription- String - URL
url- String - Location
location- String - Location Title
locationTitle- String - Location Geo
locationGeo- String, lat/lng - Filename
filename- String, optionally set the filename for the downloaded file, defaults tocal.ics. - Alarm Action
alarmAction- String (one ofDISPLAY,AUDIO,EMAIL) - Alarm Description
alarmDescription- String - Alarm Trigger
alarmTrigger- String (e.g.-PT30Mfor 30 minutes before the event)
Assumes that entry is defined by Craft and that all of the appropriate custom fields exist:
{% if entry is defined %}
{% set event = {
'title' : entry.title,
'description' : entry.description,
'startDateTime' : entry.dateStart | date('Y-m-d H:i:sP'),
'endDateTime' : entry.dateEnd | date('Y-m-d H:i:sP'),
'url' : entry.url,
'location' : entry.location,
'alarmAction' : 'DISPLAY',
'alarmDescription': entry.alarmDescription,
'alarmTrigger' : entry.alarmTrigger // e.g. '-PT30M'
} %}
{{ craft.plainIcs.render(event) }}
{% endif %}