CGCalendar + ical feed

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Locked
hasanen
Forum Members
Forum Members
Posts: 38
Joined: Tue Feb 15, 2011 8:44 am
Location: Helsinki, Finland

CGCalendar + ical feed

Post by hasanen »

I tried to search if it would be possible to subscribe CGCalendar events somehow, but I couldn't find any solution. So I ended up doing it with templates.

1. Create a template of type "CGCalendar::Event List View" and paste following code to it

Code: Select all

{assign date_format "%Y%m%dT%H%M%S"}
BEGIN:VCALENDAR
VERSION:2.0
PRODID:set some id in here
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:CGCalendar feed
{foreach from=$events key=key item=event}
BEGIN:VEVENT
DTSTAMP:{$event.event_date_start|date_format:$date_format}Z
UID:my_event_{$event.event_id}
DTSTART:{$event.event_date_start|date_format:$date_format}
{if $event.event_date_end}
DTEND:{$event.event_date_end|date_format:$date_format}
{/if}
CREATED:{$event.event_create_date|date_format:$date_format}
LAST-MODIFIED:{$event.event_modified_date|date_format:$date_format}
SUMMARY:{$event.event_title} 
END:VEVENT
{/foreach}
END:VCALENDAR
2. Create an empty template of type "Core::Page" with just code

Code: Select all

{content}
3. Create a page that is not shown in menu and is using your empty template. Disable WYSIWYG from that page and use code similar to this

Code: Select all

{cms_module module="CGCalendar" display="list" listtemplate="name of template created on step 1"}
4. You can set custom url for the page, e.g. "events.ics" and start sharing that link.

Quick and dirty, but it works :)
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3304
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

Re: CGCalendar + ical feed

Post by velden »

Thanks for sharing!

I'm not sure whether the DTSTAMP is used properly.

Further I think DTSTART end DTEND should contain time zone information. Though it might seem to work when only used by locals (people in the same time zone). When sharing event information across time zones I expect current implementation to fail.
hasanen
Forum Members
Forum Members
Posts: 38
Joined: Tue Feb 15, 2011 8:44 am
Location: Helsinki, Finland

Re: CGCalendar + ical feed

Post by hasanen »

velden wrote: I'm not sure whether the DTSTAMP is used properly.

Further I think DTSTART end DTEND should contain time zone information. Though it might seem to work when only used by locals (people in the same time zone). When sharing event information across time zones I expect current implementation to fail.
You might be correct, I'm not too familiar with the specs and I pretty much copied this from google's feed. All fixes and improvements are very welcome :)
Locked

Return to “Tips and Tricks”