Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Event Calendar: New Feature


Reply


8 Posts   2856 Views

Avatar
UncleCheese

Forum Moderator, 4094 Posts

18 June 2009 at 5:39am

The Event Calendar now supports importing ICS feeds. For those of you who are not familiar with ICS, it's a normalized data format like XML, but specifically for calendars. When you click the "add to calendar" link in the module, it returns an ICS file that is readable by your calendar to add the event to iCal, Google Calendar, Outlook, etc.

With the new import feature, you can now import a static ICS file from your calendar. Just select one, several, or all of your events in your calendar tool, and run and export to an ICS file. This can be done very easily in Google Calendar and iCal. Then, place the file in event_calendar/import/YourFile.ics. Now, go to the URL www.yoursite.com/your-calendar/import/YourFile (Note the ".ics" is not needed). You should see a series of green success messages indicating the events have been added to the database. Anything that didn't make it through will return a red error message and the index of the attempted event in your ICS file.

But wait, there's more! ICS files can also be read as continuous, dynamic feeds to a calendar. If you're using shared calendaring, chances are you have a live ICS file living somewhere out on the web. With Google Calendar, it's very easy to get a URL for your calendar in XML, KML, or ICS format. Simply click on the "Feeds" tab on your Calendar page, and enter a title and a URL for the feed you'd like to include in your calendar. Now, every time a calendar page is viewed, it will mix in the latest data from your feed(s).

The only limitation is that because we don't always know too much about the events being imported, they currently come in as Announcements only. One way around this might be to examine the length of the Content or Summary property of the event and determine, if more than X characters, the import becomes a full event, and not an announcement. I find that most events created on a calendar tool like iCal, however, do not have long descriptions, and are best served as Announcements on your calendar.

I have not thoroughly tested this change. I have had success with two iCal exports and one Google feed. Test away, and enjoy.

Avatar
mathiasmex

Community Member, 28 Posts

9 August 2009 at 11:51am

@UncleCheese

Hi, although a newbie to all this, would like no comment as follows:
Have just tested the included ics feed. Including a Google calendar via the feed tag shows up correctly, but does not allow the RSS feed from my calendar anymore. Seems there is a typing error somewhere, as without an included ics feed, first line of source code from RSS feed in my calendar starts correctly with "<?xml version="1.0"?>". Including the ics feed, first line of source code from RSS feed in my calendar starts with "_<?xml version="1.0"?>", whereas underliune is a blank one... This throws out a XML error message.
Still a nice and very usefull module, thanks for that....

Brgds

Avatar
UncleCheese

Forum Moderator, 4094 Posts

9 August 2009 at 12:48pm

A good lesson in why you should never close your PHP tags unless you're templating. That whitespace messes everything up!

Run an SVN update and let me know how it works for you. Seems to have fixed the bug for me.

Avatar
mathiasmex

Community Member, 28 Posts

10 August 2009 at 3:36am

Hi,

thanks, that worked. Just updated to r66 and RSS Feed is working now.

Brgds.

Avatar
Victor

Community Member, 128 Posts

21 November 2009 at 1:29am

My google publicly shared calendar ICS is

http://www.google.com/calendar/ical/d8miui2s0g6lr7d8q925u1o85s%40group.calendar.google.com/public/basic (.ics removed)

but my when I select Calendar (not extended) it accepts this URL but nothing is imported and attempt to access blows up

GET /testsite/test/

Line 23 in /Applications/MAMP/htdocs/testsite/event_calendar/code/iCal.php

Source

14 function iCalClean($file) {
15 return strpos($file, '.ics');
16 }
17
18 function iCalReader() {
19 $array = $this->iCalList();
20 foreach ($array as $icalfile) {
21 $iCaltoArray[$icalfile] = $this->iCalDecoder($icalfile);
22 }
23 return $iCaltoArray;
24 }
25
26 function iCalDecoder($file) {
27 $ical = file_get_contents($file);
28 preg_match_all('/(BEGIN:VEVENT.*?END:VEVENT)/si', $ical, $result, PREG_PATTERN_ORDER);
29 for ($i = 0; $i < count($result[0]); $i++) {
Trace

iCal->iCalReader()
Line 279 of Calendar.php
Calendar->importFromFeeds(DataObjectSet)
Line 371 of Calendar.php
Calendar->Events(,sfDate,sfDate,1,,)
Line 765 of Calendar.php
Calendar_Controller->Events()
call_user_func_array(Array,Array)
Line 550 of ViewableData.php
ViewableData->cachedCall(Events,,)
Line 591 of ViewableData.php
ViewableData->hasValue(Events)
Line 82 of .cache.Applications.MAMP.htdocs.testsite.event_calendar.templates.Layout.Calendar.ss
include(/private/var/tmp/silverstripe-cache-Applications-MAMP-htdocs-testsite/.cache.Applications.MAMP.htdocs.testsite.event_calendar.templates.Layout.Calendar.ss)
Line 354 of SSViewer.php
SSViewer->process(Calendar_Controller)
Line 346 of SSViewer.php
SSViewer->process(Calendar_Controller)
Line 175 of Controller.php
Controller->handleAction(HTTPRequest)
Line 129 of RequestHandler.php
RequestHandler->handleRequest(HTTPRequest)
Line 122 of Controller.php
Controller->handleRequest(HTTPRequest)
Line 29 of ModelAsController.php
ModelAsController->handleRequest(HTTPRequest)
Line 277 of Director.php
Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
Director::direct(/test/)
Line 118 of main.php

My event_calendar is 83 Victor

Avatar
UncleCheese

Forum Moderator, 4094 Posts

21 November 2009 at 3:18am

What is the error? It doesn't look like you have pasted the entire output.

Avatar
Victor

Community Member, 128 Posts

21 November 2009 at 4:28am

Yes true: Headers

[Notice] Undefined variable: iCaltoArray
GET /testsite/test/

Line 23 in /Applications/MAMP/htdocs/testsite/event_calendar/code/iCal.php

Victor

PS It is event_calendar without changes v83

Avatar
Victor

Community Member, 128 Posts

26 November 2009 at 12:08am

It looks like error was due to strange name collision: I called site "testsite" and event was "test"

Still while there is no error anymore (when I renamed event) no event is coming

I use event_calendar_r83