iCal view


1Presentation

The iCal view allows you to send feeds in iCalendar format, used to transmit events to add to a calendar.


2Usage

To use the iCal view, you must define the use of this view. In addition to this, you must assign a template variable named ical, which is an associative array with the following keys:

  • name: (optionel) Name of the calendar.
  • description: (optional) Description of the calendar.
  • events: (mandatory) List of calendar events. Each element of the list must be an associative array with the following keys:
    • name: (mandatory) Name of the event.
    • description: (optional) Description of the event.
    • html: (optional) Description of the event in HTML format.
    • date: (optional) Date of the event in 'YYYY-MM-DD' format (if this key is not defined, the dateStart and dateEnd keys must be defined).
    • dateStart: (optional) Start date of the event in the 'YYYY-MM-DD hh: mm: ssZ' format or 'YYYY-MM-DD hh: mm: ss + hh: mm' format (if this key is not not defined, the date key must be defined).
    • dateEnd: (optional) End date of the event in the 'YYYY-MM-DD hh: mm: ssZ' format or 'YYYY-MM-DD hh: mm: ss + hh: mm' (if this key is not not defined, the date key must be defined).
    • uid: (optional) Unique identifier of the event (recommended; otherwise generates a random identifier).
    • dateCreation: (optional) Creation date of the event in 'YYYY-MM-DD hh: mm: ssZ' format or 'YYYY-MM-DD hh: mm: ss + hh: mm' format.
    • organizerName: (optional) Name of the organizer of the event.
    • organizerEmail: (optional) Email address of the event organizer.

Here is an example of sending data in RSS format:

class ApiController extends \Temma\Web\Controller {
    public function getEventss() {
        $this['ical'] = [
            'name'   => 'My agenda',
            'events' => [
                [
                    'name'      => 'Dentist',
                    'dateStart' => '2025-04-07 15:30:00+01:00',
                    'dateEnd'   => '2025-04-07 16:25:00+01:00',
                    'uid'       => 'evt-01',
                ],
        ];
        $this->_view('\Temma\Views\ICal');
    }
}
  • Lines 3 to 12: Definition of the data that will be transmitted to the view.
  • Line 13: We specify that the view to use for the outgoing data is the iCal view (and not the usual Smarty view).

Note: The iCal view obviously does not need any templates, since it is the PHP data that is directly serialized.

The received data will look like this:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Temma//ICalView 1.0//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-TIMEZONE:UTC
X-WR-CALNAME:My agenda
BEGIN:VEVENT
UID:evt-01
DTSTART:20250407T143000Z
DTEND:20250407T152500Z
SUMMARY:Dentist
TRANSP:TRANSPARENT
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR

3Download

If you want the iCal feed to be sent as a downloadable attachment, define a template variable named filename, containing the file name.

Example:

$this['filename'] = 'event.ics';