Skip to content

plainlanguage/craft-plain-ics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Plain ICS for Craft CMS

A Craft CMS plugin that implements eluceo/iCal package for creating ICS files in your Twig templates.

Twig Variables

render

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);

Parameters

  • Title title - String
  • Start Date Time startDateTime - a properly formatted DateTime object in Craft.
  • End Date Time endDateTime - a properly formatted DateTime object in Craft.- Description description - 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 to cal.ics.
  • Alarm Action alarmAction - String (one of DISPLAY, AUDIO, EMAIL)
  • Alarm Description alarmDescription - String
  • Alarm Trigger alarmTrigger - String (e.g. -PT30M for 30 minutes before the event)

Example Twig Template

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 %}

About

Craft - Plain ICS

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages