iCal Events Plugin

I also uploaded a plugin which displays events from an iCal source: iCal Events. It uses import_ical.php from the WebCalendar project. Many thanks to them for writing a parser.

Update (2006-04-17): Version 1.5 released, with support for some types of repeating events and support for event URLs. If you were previously using version 1.4 of the plugin, please note the following API change: the display_events takes a single argument, formatted as a query string. For example, if you are invoking the function as follows:

ICalEvents::display_events('http://www.ufl.edu/calendar/ufCalendar.ics', time(), NULL, 3);

you’ll need to change this to:

ICalEvents::display_events('url=http://www.ufl.edu/calendar/ufCalendar.ics&limit=3&gmt_start=' . time());

This change was made to make the plugin more flexible. You now have much more control over the output; for more information, please see the readme for version 1.5.

Update (2007-04-09): Version 1.12 is out; download it from the WordPress plugin repository.

Update (2008-04-15): Adam Wolfe Gordon has another plugin of same name that might fit your needs if mine doesn’t.

146 Responses to “iCal Events Plugin”

  1. Carla Says:

    Groovy tunes! Thank you!

  2. Ghworg Says:

    Excellent plugin, thanks.

  3. Josh Says:

    This is great, but it doesn’t seem to parse events with a “Custom” repeat setting (eg, every Tuesday and Thursday from 11-12). It picks up single events just fine, but not the repeated ones. I notice that several parsers aren’t implemented in import_ical.php; is this the problem?

  4. dwc Says:

    Josh,

    You’re right - it looks like only some of the RRULEs are implemented in the parser.

    However, my WordPress plugin does not currently account for RRULEs, so for those that are implemented it might be returning incorrect data. Could you provide a sample ics file? (Please provide a link or email it to dwcNO@SPAMufl.edu.)

  5. Jeremiah Says:

    Is there any way to display an event’s location and comments?

  6. dwc Says:

    Jeremiah,

    Glancing at the parser I’m using, I don’t think it supports those fields. Could you provide a sample ics file (email it to dwcNO@SPAMufl.edu.)

  7. adame Says:

    Got this stuff while using the script for some days:

    Warning: mktime(): Windows does not support negative values for this function in ..\wp-content\plugins\ical\import_ical.php on line 194

    Any suggestion for how to make it righ? Thanks

    PS.: I’m using the last release found at http://dev.wp-plugins.org/browser/ical-events/trunk/?rev=3906

  8. Junap Says:

    hmm, can’t get it to work thus far, all I’m getting is a blank template (using a custom template with the php tag pasted in).

    I’m publishing from iCal to .Mac (don’t have webDAV access) and then pasting the url in as:

    http://ical.mac.com/rogerherbert/test (which is iCal’s suggestion)

    or

    http://ical.mac.com/WebObjects/iCal.woa/wa/Download/test.ics?u=rogerherbert&n=test.ics

    which is from the download link on the ical page from the first link.

  9. Junap Says:

    btw, the example URL given in the readme DID work! Is it perhaps something to do with .Mac?

  10. Junap Says:

    I have it working now!

    the url I eventually used was

    http://homepage.mac.com/rogerherbert/.calendars/test.ics

    which I got from the .Mac page’s ’subscribe’ button, and replaced the webcal:// prefix with http://

  11. Mac Web Design » MacTheWeb » iCal Resources - Sharing and More Says:

    [...] iCal Events is a plugin that displays events from an iCal source. [...]

  12. Will’s Blog - dwc’s Development Blog » Blog Archive » iCal Events Plugin Says:

    [...] At the moment, I’m trying out the iCal Events Plugin. [...]

  13. apacir » Wordpress y Google Calendar Says:

    [...] Para ello, he usado el plugin iCal Events. Este plugin nos permite indicarle una url con el fichero .ics, el plugin se lo baja (cacheandolo para aumentar la velocidad y ahorrar peticiones a Google), lo parsea y genera el código html necesario. Para parsear el iCal se basa en la libreria “import_ical.php” del proyecto WebCalendar. En esta página del plugin encontrareis todo lo necsario par echarlo a andar. Yo estoy usando la versión 1.5. [...]

  14. apacir » Plugins de Wordpress Says:

    [...] iCal Events Integración de Wordpress con estandard iCal. Util para integrar Google Calendar. [...]

  15. tanster Says:

    I’ve got it working at http://www.officetally.com/?page_id=65 for future events, and http://www.officetally.com/?page_id=66 for past events.

    I used to have to manually move future events to the past events page, but now I won’t have to!

    Thanks for a fantastic plugin!
    :) tanster

    P.S. One question: would it be possible to support iCal’s URL field?

  16. tanster Says:

    Wow — just uploaded your latest version and the URL field works BEAUTIFULLY.

    Feel free to point to my pages (from my previous post) as examples of your awesome plugin at work.

    Thank you again, Daniel. You rock!
    :) tanster

  17. magpiebrain » Blog Archive » London 2.0 RC 5, Wednesday May 3rd Says:

    [...] Update: I’ve added a simple block on the bottom of this site listing the upcoming London 2.0 events using dwc’s iCal WordPress plugin. There is also a specific category and RSS feed for all London 2.0 meet-up information. [...]

  18. Sokrates_d Says:

    I notice in the readme Google Calendars are mentioned as a source of ical events.

    I have tried the ical link in my Google Calendar as a source URL, but it doesn’t seem to work. Is this because the Google links don’t end in “.ics”, or am I being dim?

    Sokrates_d

  19. Sokrates_d Says:

    oops - yes I was being dim - forgot “url=” in source URL.

    Sorry :)

  20. kwirq Says:

    Hi,

    Your plugin is fantastic and thank you very much for it.

    One problem: it’s displaying my events in the time zone of my web server (GMT-4), which is two hours ahead of me. How can I display them in my own time zone?

  21. dwc Says:

    kwirq,

    Currently the plugin has no concept of time zones. I’m swamped with UF stuff at the moment, so I’d greatly appreciate a patch.

  22. Pete Allen Says:

    Repeating events by default repeat twice: once in the $events array, and once in the $repeats.
    Small patch to correct this (it might not be the best way, but it seems to work. I only test against google calendar though):
    function collapse_repeats($events) {
    $repeats = array();

    foreach ($events as $event) {
    if (isset($event['Repeat'])) {
    $r = ICalEvents::get_repeats_between($event, $gmt_start, $gmt_end);
    if (is_array($r) and count($r) > 0) {
    $rr = array_slice($r, 1,count($r) - 1);
    $repeats = array_merge($repeats, $rr);
    }
    }
    }

    return $repeats;
    }

  23. dwc Says:

    Pete,

    I’ve committed a fix for this to trunk. Please let me know if it works for you.

  24. Pete Allen Says:

    I’ll check it out later today.
    Meanwhile I fixed a problem with imported ical’s from google calendar where it has the duration of a repeat event in seconds, which wasn’t supported. This is a patch for import_ical.php from line 108-115:

    elseif (preg_match(”/^DURATION[^:]*:(.+)\s*$/i”, $buff, $match)) {
    $substate = “duration”;
    $durH = $durM = $durS = 0;
    if ( preg_match ( “/PT.*?([0-9]+)H/”, $match[1], $submatch ) )
    $durH = $submatch[1];
    if ( preg_match ( “/PT.*?([0-9]+)M/”, $match[1], $submatch ) )
    $durM = $submatch[1];
    if ( preg_match ( “/PT.*?([0-9]+)S/”, $match[1], $submatch ) )
    $durS = $submatch[1];
    $event[$substate] = $durH * 60 + $durM + $durS / 60;

    If I get round to it I might add code to allow the events to be displayed as “This week” “Next week” “Next month” style.

    Thanks for all the work on this! It’s a really useful plugin..

    Cheers,
    Pete

  25. dwc Says:

    Thanks, Pete. Applied to trunk as revision 6002.

  26. Brian Says:

    Is there a way to display the time the events ends? Seems I can only get the starting time.

  27. dwc Says:

    The end time should be displayed if it is different than the start time. Could you email me a link to or a copy of the calendar which is causing problems?

  28. Brian Says:

    Sent.

  29. Zodiac Says:

    Hello Daniel,
    I’m testing your Plugin to provide an Event-Calendar-Page.

    Three different programs/plugins that creating an ics-File:
    Mozilla Sunbird (german)
    and these two plugins:
    http://blog.firetree.net/2005/07/18/eventcalendar-30/
    http://garrickvanburen.com/wordpress-plugins/wpical/

    The Sunbird ics-File seems to have a failure, because all Events are repeated three times.

    The EventCalendar-Plugin ics-File didn’t display the events day if the events is on today. (This is displayed on May 29 when event is on May 29)
    * 29. März 2006: Programmtest Zwei
    * : Programmtest

    Only the WP-ICal-Plugin seems to function without problems. But there I have to set the timestamp AND the Start/End-Time for the Plugin to have my EventCalendar.

    Is there any chance to make your plugin work with Sunbird-ics-Files or to make the day visible if it is today?

  30. Zodiac Says:

    Got my mail?

  31. Conrad Says:

    Hey ~ You’re plugin was just what I was looking for, but I seem to be doing something wrong since it doenst work. I get this error: Warning: fopen(url=http://www.epiphanyeyc.com/phpicalendar/calendars/EYC%20Events.ics&limit=3&gmt_start=1151284259) [function.fopen]: failed to open stream: No such file or directory in /home/epiphany/public_html/wp-content/plugins/ical-events.php on line 102
    Error opening url=http://www.epiphanyeyc.com/phpicalendar/calendars/EYC%20Events.ics&li

    I’m 100% positive that the url is correct…so why isn’t it working?

  32. dwc Says:

    Conrad,

    It sounds like there is a problem in your display_events call. Try this:

    <?php ICalEvents::display_events('url=http://www.epiphanyeyc.com/phpicalendar/calendars/EYC%20Events.ics&limit=3&gmt_start=' . time()); ?>

  33. Conrad Says:

    Thats exactly the same php code that I already have. For any reason could it be the space in the filename? I don’t see why that would be a problem but thats the only thing I can stick out. I have to go right now but when I’m back I’ll try removing the space in the filename.

  34. dwc Says:

    Conrad,

    Ah, I missed that last night. Try the following:

    <?php ICalEvents::display_events('url=http://www.epiphanyeyc.com/phpicalendar/calendars/EYC%2520Events.ics&limit=3&gmt_start=' . time()); ?>

  35. Conrad Says:

    Ok that didnt work either - but I tried taking the space outta the file…its displaying the events now, but it seems there’s in error in my ical file itself - Unsupported iCal COUNT value “COUNT=2″
    Unsupported iCal COUNT value “COUNT=2″
    # Sun Jun 25 - Sun Jul 2: Mission Trip - New Orleans
    # Mon Jun 26 - Mon Jul 3: Mission Trip - New Orleans
    # Tue Jun 27 - Tue Jul 4: Mission Trip - New Orleans

    Unsopported iCal COUNT value “COUNT=2″ ?
    What does that mean?

  36. dwc Says:

    Unfortunately the code used to parse iCalendar data does not support all the different types of repeating events. I haven’t had time to add support for this type yet.

  37. Conrad Says:

    Ok thanks though. I worked on the ical-events.php to get it to view some of my repeating events more accuratly. This is an awesome plug-in. Thanks for the hard work.

  38. Conrad Says:

    Hey
    I thougth I might let you know, i modified the 2 php files and it seems to be displaying repeating events correctly. You can see it at http://epiphanyeyc.com - in the brown column on the right. The main thing i did was remove the error handlers in the parser and a few things in the events file…I didn’t do much so I don’t understand why it would work…but it seems to work just the way I wanted it to…I’m sure it doesn’t but it works better than it did before.

  39. dwc Says:

    Conrad,

    Thanks for the info. I’ll try to take a closer look soon.

  40. matt b Says:

    Is there a built in way to consolidate events for a given date? That is to say, if there are two events on the same date, only show the date once.

    Thanks.

  41. dwc Says:

    matt,

    There’s no built-in way to do this currently. I’d suggest that you use ICalEvents::get_events to write a custom display function. You can put it in your own plugin:


    <?php
    /*
    Plugin Name: My iCal Events
    */
    function my_ical_events_display($url, $gmt_start, $gmt_end, $limit) {
        $events = ICalEvents::get_events($url, $gmt_start, $gmt_end, $limit);
        $output = '';
        foreach ($events as $event) {
            /* Custom view code here */
        }
        return $output;
    }
    ?>

  42. matt b Says:

    thank you for the information. will do.

  43. Farhan Says:

    How do I display displays from the current day, and not just from the current time forward?

  44. dwc Says:

    Farhan,

    Try the following parameters for gmt_start and gmt_end:

    $time = time();
    $gmt_start = mktime(0, 0, 0, date('m', $time),date('d', $time),date('Y', $time));
    $gmt_end = mktime(23, 59, 59, date('m', $time),date('d', $time),date('Y', $time));

  45. wes Says:

    I’m trying to implement iCal Events into my new blog… but I get this error..

    Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in /home/.kazak/wyoakum/twentyeight19.org/wp-content/plugins/ical-events.php on line 150

    I’m using Dreamhost… apparently they have disabled fopen for security reasons. Also, I’ve seen that this has been a problem with a number of different plugins… with differing solutions… possibly using cURL? I’m not too sure… I’m no programmer… so, for me, ideally there would be a section of code in ical-events.php that I could replace to make it work.

    If you have a chance, could you help me out with this? If you can’t get to it, no problem. Just let me know so I can know to keep on looking for a solution. Thanks for all the good work!

  46. dwc Says:

    wes,

    I’ve committed support for cURL via the url-cache plugin.

    I’d appreciate it if you could test it out by installing url-cache and then downloading the “in-development version” of ical-events.

  47. wes Says:

    dwc -

    thanks for the help… i’m not sure I can get to it today. But, I’ll give it a shot as soon as I can.

    Thanks a ton.

  48. wes Says:

    dwc -

    actually, I realized how easy that would be and went ahead and tried it out.

    I haven’t tried customizing the output or anything… but, good news… it seems to be working fine! I first just used the example from the readme file… which worked… so then I tried it quickly with a couple of different google calendar iCal feeds and those worked great too.

    Thanks for the help! I will get around to trying to customize the output and such soon.

    by the way, you can see my implementation at…

    http://www.twentyeight19.org/calendar/

    obviously, I’m still working on the site though, so cut me some slack ;)

  49. dwc Says:

    wes,

    Looks good! Thanks for testing out the development version.

    I’ve released version 1.8 of the plugin (no functional changes from the development version).

  50. emeff Says:

    Great plugin: I love it. Thanks!

    I have just one wish: I would like to display the previous event from now and the next following events (limit=3), but I can’t ‘fetch’ the previous event with the ’start date’ tag, because it’s an unknown amount of days away.
    To make it clearer: I have an Google Calendar that includes the events of my favourite hockey team and after every game I add the results (scores). With iCal Events I want to display the result of the last game (2 to 6 days ago) and the following 2 game (preview). GMT_START will not help (IMO) because it captures not exactly the last event.
    Is it possible to deliver a solution for this requirements? Thanks for any feedback!

  51. dwc Says:

    emeff,

    For that type of situation I recommend using the ICalEvents::get_events function. It’ll be a little more work, but will give you complete control over the output.

    See an above comment for a bit of sample code. Good luck!

  52. Eric Says:

    Seems not working any more after new updates. New version available yet?

  53. dwc Says:

    Eric,

    Are you receiving an error message?

    Also, are you using the url-cache plugin?

  54. CogDogBlog » Barking » Calendar Data PITA and Banging On WordPress Says:

    [...] The closest for the sidebar publishing was the iCal-events plug-in for WordPress, which could use the iCal data format published by gCalendar. What’s nice is it bad built in caching scheme, so it was not hitting gCalendar for every page load. It had the ability to sort future and past events differently, although I think that an events past calendar should list them in order with the most recent, and then receding in time (this plugin listed the oldest, and moved forward). I thought some simple hacking of the loop controls might get me there, but I only succeeded in making rivers PHP errors. [...]

  55. Mark Says:

    Cool plugin!

    Any news about the ‘Unsupported iCal COUNT value “COUNT=2?’ message? I’m also getting this message. Any idea if and when this will be implemented? Any patch I can apply?

    Thanks.

  56. dwc Says:

    Mark,

    At the moment events that repeat using COUNT are not supported. Sorry!

    I’d love it if someone came up with a patch to support these events; if you’re interested, email me and I’ll help you get started.

  57. Seth Kinast’s Blog » Stalking done right Says:

    [...] That still wasn’t idea, but I read the comments of that blog entry to find that there was a WordPress iCal parser! It was easily to grab and install, but it only showed events that had already passed. So I hacked [...]

  58. lars Says:

    Nice plugins, thanks!

  59. Dan Says:

    Is there any way to get links from my Google Calendar description field to import correctly? It does everything great, but in the description field I have a few links for each event that display as html.

  60. irry Says:

    Hi Dan, the download you are offering on the official wordpress plugins site is 1.12. On this page you are offering 1.5 (top of page) and 1.8 further down this page (dated August 20th, 2006). Is 1.8 the one you would prefer us to use?

  61. dwc Says:

    Dan: I can’t get Google Calendar to accept HTML in the description field. When I try to enter a link (e.g. <a href="http://www.ufl.edu/">UF Home Page</a>), it strips it.

    RFC 2445 doesn’t explicitly disallow HTML but it does say that the description field should be for human-readable text. Could you provide a link to the calendar you’re trying to display (email me if it isn’t public) and an example of how you’d like it to show up?

    irry: 1.12 is preferred, I’ve updated this post to reflect this. Thanks!

  62. justine Says:

    Hey! I just added this plugin to my wordpress, and the default events show up just fine. But, when I try to display my google calendar events, I get an error:

    “iCal Events: Error parsing calendar [http://www.google.com/calendar/ical/jrjvl31o7cs2v101avm28ru95s@group.calendar.google.com/public/basic.ics]”

    When I un-commented the parser debugging code in import_ical.php, it shows the correct calendar title, description, timezone, etc. What could be the problem? Did I forget an important step? Thank-you!

  63. dwc Says:

    justine,

    Could you let me know what version you’re using and what code you’re using to invoke the plugin?

    The following worked for me using version 1.12:

    <?php ICalEvents::display_events('url=http://www.google.com/calendar/ical/jrjvl31o7cs2v101avm28ru95s@group.calendar.google.com/public/basic.ics&limit=3&gmt_start=' . time()); ?>

  64. Benjamin Says:

    I made two modifications to ical-events.php
    1) added force reload:
    in function function cache_url($url)
    change if (! file_exists($file) or time() - filemtime($file) >= ICAL_EVENTS_CACHE_TTL) {
    to
    if (! file_exists($file) or time() - filemtime($file) >= ICAL_EVENTS_CACHE_TTL OR $_GET['ical'] == ‘reload’) {

    now when you call your url with ?ical=reload it will force a reload

    2)for gcal, added linkify description
    modified or added the following lines
    62-62
    if (! isset($r['link_description'])) $r['link_description'] = true;
    if (! isset($r['link_text'])) $r['link_text'] = ‘Link’;
    66
    ICalEvents::do_display_events($r['url'], $r['gmt_start'], $r['gmt_end'], $r['limit'], $r['date_format'], $r['time_format'], $r['before'], $r['after'], $r['before_date'], $r['after_date'], $r['use_summary'], $r['before_summary'], $r['after_summary'], $r['use_description'], $r['before_description'], $r['after_description'], $r['replace_newlines_with'], $r['use_location'], $r['before_location'], $r['after_location'], $r['use_url'], $r['echo'], $r['link_description'], $r['link_text']);
    74
    function do_display_events($url, $gmt_start, $gmt_end, $limit, $date_format, $time_format, $before, $after, $before_date, $after_date, $use_summary, $before_summary, $after_summary, $use_description, $before_description, $after_description, $replace_newlines_with, $use_location, $before_location, $after_location, $use_url, $echo, $link_description, $link_text) {
    106
    if ($link_description == 1) {
    // add link_description
    $event['Description'] = ‘‘.$link_text.’‘;
    }
    $output .= str_replace(”\n”, $replace_newlines_with, $event['Description']);

    now in the php code in your sidebar, add &link_description=1&link_text=Goto or whatever. This of course only works when the description field only contains a link. I suppose with a preg_replace I could be fancier or somesuch, but this works for me

  65. Benjamin Says:

    i decided to make it a bit easier to work with and robust when linkifying the description. I removed link_text and changed
    106 to
    if ($link_description == 1) {
    // add link_description
    $bblink = array(’[[','][',']]’);
    $htmllink = array(’‘,’‘);
    $event['Description'] = str_replace($bblink,$htmllink,htmlentities($event['Description']));
    }

  66. Benjamin Says:

    Is there some kind of limit on the description length? I’m getting my ics from google cut off and I think it has to do with the description field

  67. dwc Says:

    Benjamin,

    Not that I know of. A few of my events have a long description on Google Calendar and they come across okay.

    Could you provide an example of the behavior you’re seeing or maybe even a link to the calendar so I can check it out?

  68. Benjamin Says:

    just to be sure, i sent some patch code earlier and i’m not sure it posted, maybe caught as spam?

  69. Benjamin Says:

    here’s the source http://jewishmeetup.com/chicago/ical-events.phps (the directory is my page though I admit that I manually downloaded that ics file as for some reason it wasn’t completely downloading. is that an issue with the wp_remote_fopen ?) two changes: manual reloadwith ?ical=reload and bbcode links in the description

  70. dwc Says:

    Benjamin,

    Your first two comments were marked as spam - sorry about that!

    I like your idea for allowing a manual reload of the calendar. It should probably be restricted to administrators, so malicious users can’t get you in trouble with another server.

    On BBCode processing, my initial feeling is that it should be left to another plugin or template function. For example, with your WordPress theme you can provide a functions.php file. In this file you could write a mytheme_bbcode_links function that replaces the appropriate patterns with HTML links and then wrap your ICalEvents::display_events call:

    echo mytheme_bbcode_links(ICalEvents::display_events('url=...&echo=false'));

  71. Benjamin Says:

    Without creating an admin page, I thought I could check something like this
    if ($_GET['ical'] == ‘reload’ && !empty($_COOKIE[USER_COOKIE]) &&
    wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true))
    to see if the user calling the ?ical=reload is authorized as an admin, but I don’t know how to specify the user level (wp_getuserinfo)?

    anyhoo, great plugin. still need to figure out why it’s not downloading the whole ics from google…

  72. Benjamin Says:

    fwiw, I can’t get it past 3856 bytes on my google calendar. I’ve been futzing with some file download stuff with fwrite and fread on the php pages to no avail.

  73. dwc Says:

    Is your calendar really large? I’m wondering if your wp_remote_fopen call is actually using cURL and timing out.

  74. Benjamin Says:

    No, I just started it. It has like 10 things on it. I’ve tried all the methods fopen, curl, get_file_contents, and buffered output. To contrast, another ics on another server is like 20k and downloads in its entirity. mine is like 4k

  75. Benjamin Says:

    I’m using the private ical basic and set it not to update as often and it seems to be working now. http://jewishmeetup.com/chicago/ical-events.phps However, the encoding of the &acir; apostrophe isn’t working, though utf_decode in the import php at least reduces the mess to a ? Google Calendar ics seems to be ISO-8859-1 and my wordpress site is UTF-8

  76. Benjamin Says:

    I know I’m posting a lot.. I’m thinking a lot though :) So, if I want to highlight my repeating events separately, I changed to one repeating event

    define(’ICAL_EVENTS_MAX_REPEATS’, ‘1′);
    and added the second line
    $events = ICalEvents::sort_by_key($events, ‘StartTime’);
    $events = ICalEvents::sort_by_key($events, ‘rrule’); //sort by rrule

    so that after it sorts by start time, it would sort them by rrule to concentrate them all together, but perhaps because they don’t all have rrule, this duplicated some events… hmm..

    my goal is something like
    Event: Mondays
    Event: Tuesdays
    Event: Monthly
    Event1
    Event2
    Event3
    etc.

  77. Benjamin Says:

    fwiw, I added a function display_two_events that merges two icalendars http://jewishmeetup.com/chicago/ical-events.phps

  78. dwc Says:

    Benjamin,

    No problem - it’s interesting to see how you’re extending the plugin.

    I’ve committed a couple of changes so far based on our discussion. The first is support for reloading calendars. The second is character set conversion support. Let me know if those work for you.

    I don’t understand why the Google Calendar private URL seems to be working, while the public one isn’t. Very odd, but I’m glad there’s one that gives you the results you want.

    For displaying two calendars and highlighting repeating events, you might be interested in writing a custom display plugin.

  79. Benjamin Says:

    cool diffs, thanks. I’m just happy that it’s working now, and beautifully with the merged calendars. (though there seems to be an issues with events that repeat daily or monthly while weekly works fine…. I’m looking into it later tonight)

  80. Benjamin Says:

    I added the ability to click a summary to show or hide a description. http://jewishmeetup.com/chicago/ical-events.phps This way I can have longer descriptions and it doesn’t clutter the page. It’s more a hack than a mod, but it works just fine in ie7 and firefox 2

  81. Dom Says:

    I am some what of a newbie, so any help is appreciated, even being pointed in the right direction with an example somewhere. But I am trying to use ical events and wondering if it is possible to use javascript to bring it into my homepage (index.html) (not wordpress) on right hand side listing all events for the next 30 days. Like I said, any help is greatly appreciated. Thanks
    -Dom

  82. dwc Says:

    Dom,

    It’s possible but it would require a bit of hacking. You could create a page using a custom WordPress template that calls only the ical-events plugin and then include that page using server-side includes or perhaps even AJAX.

    It might be simpler to move your homepage into WordPress - you can use a page for the WordPress front page. If you’re concerned about load on the server, you can use wp-cache to reduce the cost of serving a page from WordPress.

    Hope this helps!

  83. The DWC Factor » Conscious Design Says:

    [...] thanks to dwc and his iCal wordpress plug-in. The UF Student Financial Affairs calendar is now dynamically driven.   « WORDCHASM [...]

  84. Andy Says:

    dwc = lifesaver. thanks for the plug-in.

  85. mantra Says:

    I can not get the updates in calendar to show on the site. A Cahe problem? How to fix it?
    And how to get some extensions on the web page - as in date, place, repeat, past events etc?

  86. Geordnete Liste aller im Blog Karneval vorgestellten Wordpressplugins » Artikel » NSAHs Blog Says:

    [...] iCal Events: zum Anzeigen von iCal Ereignissen vorgestellt von stohl.de [...]

  87. dwc Says:

    mantra,

    By default the plugin caches each calendar for 24 hours. See the FAQ for more.

    You also can control the output using some of the options to the display_events function. The various options are described in the readme.

  88. Jonathan Uhlmann Says:

    Hi

    Thank you a lot for your plugin! Is there a possabillity to have the Strings (like %B) in the different language? For example in german?

    Thankx for your help!

  89. Jonathan Uhlmann Says:

    I got it!
    When you use setlocale like this
    [code]
    setlocale (LC_ALL, ‘de_CH’);
    ICalEvents::display_events…..
    [/code]
    it works.

    I would like to make a feed (rss or atom) from a .ics file. Do you have planed to integrate this feature?

  90. dwc Says:

    Jonathan,

    Thanks for the tip about l10n!

    I haven’t added real l10n support, but there aren’t many strings that need it in the plugin. (Most of them are error messages.)

    As for making a feed, the plugin itself probably won’t get this feature. However, you can create one using a page template that calls the ical-events plugin, similar to how a custom display plugin calls it. If you’re interested, I’d love to have such a template provided as an example with the plugin (with full credit going to you, of course)!

  91. Excellence-Blog » Blog Archive » Endlich! Das tollste Layout seit Bestehen dieses Blogs! Says:

    [...] Kalender wurde über das Plugin ICal Events realisiert. Darüber kann ich aus verschiedenen Kalendern, die einen ICal-Feed zur [...]

  92. Jay Wollmann Says:

    Glad to see another techie using apple software!

  93. Jonathan Uhlmann Says:

    Hi

    I’ve got another question: If I have an event who is today, it only shows the time. Is there a possabillity to render also a text?
    Example:
    instead of: “@ 19:30″ it should display “Today @ 19:30″

  94. dwc Says:

    Jonathan,

    That isn’t possible out of the box. You could modify the format_date_range_part function to handle that.

  95. Robert Spencer Says:

    Hi dwc,

    I just wanted to post to let anyone know that if they are putting CSS into the custom fields (before_description or similar) that they don’t need to worry about the quotes around classes etc, the plugin puts them there for you.

    Also, I’m trying to create a custom date that uses a short form of the date for display but has an abbr tag with the full date… but if I put the html into the date format it is escaped and outputs literally and if I put it into before_date then it doesn’t have context. I want something along the lines of 14.07.07 and would prefer not to modify the format_date_range_part function if I could avoid it :)

  96. Dave S. Says:

    Great plugin. Worked like a charm from the moment I set it up. I am running into one problem though. I have events defined in my Google calendar that occur on the second Tuesday of every month. In my Google calendar view things are good, but when I take a look at them on my blog, they are showing up as though the event takes place every Tuesday of every month. Any idea why?

  97. dwc Says:

    Dave,

    Unfortunately some repeating event types aren’t supported currently. Where possible I’ve extended the parser, but it still has a few holes.

    I’d appreciate help in adding support for events like the one you’re describing - if you’re interested, let me know.

  98. Cephalopodcast.com - The Ocean Podcast Says:

    [...] iCal Events Plugin for Wordpress [...]

  99. Kretzschmar Says:

    I want to use this great plugin on a german blog. The date is correctly localized (thanks Jonathan - set_locale …). BUT all events with german lings (äöü) aren’t shown correctly (Jörn Geburtstag instead of Jörns Geburtstag).
    Is this a problem of the ical file of google calendar or are foreign languages not correctly decoded (or supported)?

  100. Kretzschmar Says:

    I couldn’t wait, so I made a first fix on my own. The problem is the parser (import.php). On utf_8 encoded blogs (the typical german encoding of Wordpress) the summary needs to be decoded properly.

    On line 83 I changed:
    $event[$substate] = $match[1];

    to:
    $event[$substate] = utf8_decode($match[1]);

    I just need to check if there are other fields with lings (äöü). Right now this is a first fix that works here.

  101. Kretzschmar Says:

    Just downloaded your already fixed version you posted above. Next time I really should read better.
    I made a hack, but you made it beautiful. Thanks.

    I would like to group events (all events of one month) - e.g.:

    January:
    Mo, 01.01.07: Swimming
    Fr, 07.01.07: Cycling

    Febuary:
    Fr, 05.02.07: Hiking

    etc.

  102. dwc Says:

    Kretzschmar,

    Grouping events by month is most easily achieved using a custom display plugin. It requires a bit more work on your part, but you get full control over how the events are displayed.

  103. Kretzschmar Says:

    Sorry, but I think this is really beyond my skills. Do you plan to support some more styling to the output in the future?

    E.G.
    - only show date once if starting day end end day is same
    - group month
    - Show all events of same day

  104. Free-Loops.com Says:

    Hey on my Wordpress site with that plugin the time is off how do i fix this? It doesn’t read from the windows clock like javascript does?

    Thanks ahead of time
    Mike Koenig

  105. dwc Says:

    Kretzschmar, not in the immediate future. The plugin is largely stable at this point. If someone provided a patch that didn’t affect existing functionality I would most likely add it, though.

    Mike, your calendar is probably in a different time zone than your server. Check if you can set it in your calendar program.

  106. Kretzschmar Says:

    I wrote a widget for your excellent plugin. This is something in my scope. Right now it is only part of my own theme dkret2. I could make it work standalone and send you my changes if you want.

    I had one problem though. I tried to load Wordpress default date and time format (with get_option(’date_format’)) to make it a bit more automatic but I failed because Wordpress doesn’t use %. Maybe that is something you could add in the future. If no date or time format is set, use the default of Wordpress.

    AND PLEASE everybody having more knowledge: provide a patch as dwc suggested.

  107. Andrew Kronemyer Says:

    After a ridiculous amount of searching and sampling various event calendar plugins, this is literally the only one that has proven to be both robustly programmed and satisfactory for my purposes. Thank you for writing this excellent plugin!

  108. Joe Hamilton Says:

    My list of events are Art exhibitions that run for around a month each. I would like the events to appear on my site until the exhibition is over.
    At the moment the events disappear after the first day of the exhibition.
    Can anyone suggest a hack that would allow this.
    thanks!

  109. carl Says:

    Thanks a lot for providing this plugin! It’s really useful, and the only stable alternative I’ve found so far.

    I’ve almost got it configured perfect for my needs, but I’m just not skilled enough for the last little part:

    Right now I get it to display like this:

    fri 2. nov 19:30 - 21:45: [eventname]

    using the following code:

    But I really want to get rid of the ending time, it just takes up place.
    And ideally, want it to display devided into two lines. That leaves my perfect goal like this:

    fri 2. nov
    19:30(start time only): [eventname]

    Would be great I could get some help on this one! Hopefully it’s just a little tweak of the arguments in the string?

    regards
    Carl

  110. carl Says:

    sorry, the code didn’t show up corectly. here it is (without the php tags:)

    setlocale(LC_ALL, ‘mylocale’);
    ICalEvents::display_events(’url=mycalendar.ics&limit=3&use_description=0&use_location=0&time_format=%H:%M&date_format=%a %e. %b&gmt_start=’ . time());

  111. Mary-Ann Horley Says:

    I notice on wp.org/extend that this plugin is only listed as compatible with 2.2, I’ve got it working on a few 2.3 installations so you might want to update that. Great plugin!

  112. dwc Says:

    @carl: That isn’t currently supported, but it would be possible to add new flags for using the start time and using the end time. For example, you could add a flag named use_start_time and another called use_end_time.

    @Mary-Ann Horley: Thanks for the info! I’ve updated the compatibility statement, which will be live in the next release.

  113. Nick Smith Says:

    Hi, thanks for this plugin, definately the most useful I’ve found. One question, I’m using the code you posted at the top of this page, I’m trying to get this plugin to only display future events. Specifically, the section of code I’m using that I think will do this is “gmt_start=’ . time()”. When I display the feed you used in your example (http://www.ufl.edu/calendar/ufCalendar.ics) the first item it displays is “Fri Oct 12 6:45 PM: The Philosophy Department presents the “Necessity and Possibility” Conference” - which is a while ago. I’m wondering what kind of date format I need to pass the plugin, is the unix timestamp that time() returns OK? I guess it might be something wrong with the value my host’s server is returning. Otherwise I don’t really know what I’m doing wrong. Thanks for any help.

  114. Daniel Says:

    Hi, this looks like a plugin I would like, so i tried it. I use it in wordpress 2.3 togehter with KB Countdown Widget. It doesn’t seem to work, and I get this error:

    “iCal Events: Could not fetch [http://www.google.com/calendar/ical/navet.kalender%40gmail.com/public/basic.ics]”

    The calendar is fully available to all, so I don’t see how it can’t fetch it. Do you?

    Thanks!

  115. dwc Says:

    @Nick Smith: gmt_start is the right parameter. For example:

    ICalEvents::display_events('url=http://www.ufl.edu/calendar/ufCalendar.ics&gmt_start=' . time());

    You can check your server’s time using date(’r');

    @Daniel: I’m not having any problems displaying events from that URL. It sounds like wp_remote_fopen isn’t working on your installation. You’ll need cURL support or allow_url_fopen on in PHP.

  116. Geordnete Liste aller im Blog Karneval vorgestellten Wordpressplugins « Artikel « Nils sah's Says:

    [...] iCal Events: zum Anzeigen von iCal Ereignissen vorgestellt von stohl.de [...]

  117. Benjamin Says:

    I like using this plugin with the php code widget to insert the code. Also, I found a bug in my mod, that when displaying one feed, you need to add in the display_events paramaters that url2 = “” as a default

  118. bla » Linkliste Plugins Says:

    [...] http://dev.webadmin.ufl.edu/~dwc/2005/03/10/ical-events-plugin/ [...]

  119. Plugin de Kostracal Says:

    [...] proyecto: iCal Events te permite mostrar una lista de eventos utilizando como fuente ical. Eso esta chulo. Ademas como en [...]

  120. Webmaster Forum Says:

    WordPress Plugins: Inhalte erstellen, bearbeiten,anzeigen…

    Dies ist ein Teil der WordPress Plugin Serie. Weitere Teile findest Du unter (wird später erweitert). Die Funktionsweise der Plugins wird nur knapp erläutert, damit man sich schnell einen Überblick un……

  121. Christopher Says:

    Great plugin, just what I was after.
    Have managed to use options and tweak display to get a format I like, but I would like to display events from now to end of year but can’t get gmt_end to work.
    What is the correct way / format to use gmt_end in a url?
    Many thanks.

  122. Christopher Says:

    Possibly not good form in answering my own question…
    In the cold light of day I figured it out:
    mktime(0, 0, 0, 12, 31, date(”Y”))

  123. Andrew Schmitt Says:

    While a comment above indicates the plugin inserts quotes around class declarations automatically (http://dev.webadmin.ufl.edu/~dwc/2005/03/10/ical-events-plugin/#comment-4335) I can’t get this to happen in my install. As a result I am getting many errors with xhtml checking.

    I’ve tried to escape out the quotes in the class declarations but that doesn’t work. I don’t expect the plugin to add them manually and may just hack the core files to get what I need but I would rather not. Any ideas?

    Here’s how I call the code from the sidebar.

    `
    Upcoming Events

    ‘;
    $queryString .= “&after=”;
    $queryString .= “&before_date=”;
    $queryString .= “&after_date=”;
    $queryString .= “&use_summary=true”;
    $queryString .= “&before_summary=”;
    $queryString .= “&after_summary=”;
    $queryString .= “&use_description=0″;
    $queryString .= “&replace_newlines_with=”;
    $queryString .= “&before_description= - “;
    $queryString .= “&after_description=”;
    $queryString .= “&use_location=0″;
    $queryString .= “&before_location= (”;
    $queryString .= “&after_location=)”;
    $queryString .= “&use_url=0″;
    $queryString .= “&gmt_start=”;
    ICalEvents::display_events($queryString . time()); ?>

    `

  124. Thomas Says:

    Trying this great plugin at the moment, but I’m struggling with localization. I want to have the names of the days in German and tried with “setlocale(LC_ALL, ‘de_CH’);” before the display_events…, but nothing happens. Ever tried that?

  125. dwc Says:

    Thomas,

    I’ve heard reports that using setlocale like that works, but I’ve never done it myself.

  126. Nat Says:

    Hi,

    I’m pulling my calendar off of another website I manage, and there is a time difference between the two calendars of two hours — the new calendar uses ical-events and is two hours earlier than the original calendar. I suspect that this caused by my server, which is in Mountain Time (I am Eastern Time). However, I am managing both sites off of the same server, so I’m not sure what I should do. Is there a way I can shift my new calendar two hours forward?

  127. batna Says:

    Where is my template? where to add “ …

    i have installation problem…help.

  128. dwc Says:

    @Nat: You could try adjusting the timezone using the PHP_TZ environment variable. I’ve never tried this, but it’s worth a shot.

    @batna: Please refer to the FAQ for installation help.

  129. dave Says:

    this is a great plugin that works around the horrid XML that Google Cal outputs. The standard WP rss widget is useless because of the Google Cal output, but this is perfect. My question is, can I add some before/after control for the timestamp? It seems that the timestamp gets wrapped inside the before/after for the date field. I’d like to put a linebreak between the date and timestamp and after the timestamp. Thanks!

  130. dwc Says:

    dave,

    You could try adding the appropriate HTML markup to the date_format and time_format, though I’m not sure if that will work.

    Otherwise, you can add your own tweaks to format_date_range and format_date_range_part to add a linebreak.

  131. dave Says:

    thanks for getting back to me quickly. i tried some stuff in both those spots already and it doesn’t seem to want to work with me.

  132. Mark Says:

    Just started to use the plug-in, and find it to be excellent for my needs.

    I’m no coding expert, so need a little help. I would like to change the text colour of the date in my display. Is this possible.

    Many Thanks Mark

  133. Hussain Says:

    How to send the ical event to a mail using PHP. I tried but it sent as an attachment. But i want to display the events in the mail. If i send the mail it should automatically added to my calendar events. Pls help me(Thanks in advance).

  134. Mark Says:

    I’ve sorted the formating of my date display, I found I could add a tag in the ical-events.php. add call it from the wordpress stylesheet

    Cheers Mark

  135. John_C Says:

    Nat and kwirq -
    I had the same problem with the time being offset. I added some code to ‘import_ical.php’ to add 2 hours to the time. (That happens to be the timezone difference between the webserver and the site I am working on.) I’m not sure if this is the correct place to adjust the time, but it seems to work.

    in the icaldate_to_timestamp function:
    look for “$H = substr($vdate, 9, 2);”

    change it and add the following:
    $H = substr($vdate, 9, 2) + 2; // JC 4/16/08 — added “+2″ to hopefully adjust the server’s timezone to match mine.
    if ($H > 23) { // $H is 24 or 25
    if ($H > 24) { // if $H is 25 add a day
    $d = $d + 1;
    }
    $H = $H -24; // $H will be either 0 or 1
    }

    A few lines later in the code, there is a comment that says “Problem here if server in different timezone”, but the code was never written to fix this problem. I don’t know PHP very well and I couldn’t find a way to access or change the the timezone for my web account. I also tried to use “date_default_timezone_set” function, but it didn’t work. I think it is because it is only available in PHP version 5.1.0 and up and I am probably using an earlier version. It seems like it would be EASY (for someone with a little more knowledge than me) to make the iCal timezone match the WordPress timezone.

  136. trendysetgo Says:

    If go into my google calendar, and put a link in the ‘what’ field. It get’s displayed as the html code, and not an actual link. I know someone above mentioned something about this, but in the description field, which i think is different than the ‘what’ field. would that be the summary?

    Is there something i can do to change that?

  137. dwc Says:

    @trendysetgo: The iCalendar format supports a separate field for URLs, which Google Calendar doesn’t let you use.

    You can modify the plugin for your needs by changing do_display_events to something like the following:

    if ($use_summary and $event['Summary']) {
        $output .= $before_summary;
        $output .= ‘<a href=”‘ . htmlentities($event['Summary']) . ‘” rel=”nofollow”>’;
        $output .= htmlentities($event['Summary'], ENT_COMPAT, $charset);
        $output .= ‘‘
        $output .= $after_summary;
    }
    

    Code is untested and any modifications you make won’t be supported, but hopefully this gives you an idea of how to make it work.

  138. DeezJee Says:

    Hello,

    I really do love your plugin, but I wonder if it’s possible to have events displayed the complete day. So even if the event is passed, but it’s still the day of the event it will be still visible?

    Thanks!

  139. Russ Says:

    I’m using iCal events to display both future events and past events on my website (http://www.thexyzaffair.com). The problem is I’m limiting the “past events” display to 8 events, so it only shows the earliest 8 events. I want it to show the 8 most recently passed events.

    Is this at all possible? How do I accomplish this? Do I need to change the structure of the loop? Thanks!

  140. dwc Says:

    @DeezJee: You should be able to calculate values for gmt_start and gmt_end that allow you to do that.

    @Russ: A custom loop sounds like the easiest way to accomplish that.

  141. Russ Says:

    Awesome! One small problem… I have no idea how to create a custom loop to do that. Any resources you could point me to? Any hints? Thanks a million!

  142. dwc Says:

    Russ,

    You can write a simple plugin wrapper. Use the code in do_display_events as an example.

  143. DeezJee Says:

    Isn’t gmt_start and gmt_end not for limiting the events to be displayed?
    I only want the events NOT be removed from the list before the day has finished. Something like an allday event but with the start time displayed

  144. dwc Says:

    DeezJee,

    How about a gmt_end that matches with 23:59:59 for the current day? That would keep events for today on the list until the day has finished. For example:

    $gmt_end = gmmktime(23, 59, 59);

  145. DeezJee Says:

    Where should I place this code? Or do I have to replace the some code with this one?

  146. dwc Says:

    Pass it to your display_events call:

    ICalEvents::display_events('url=http://www.ufl.edu/calendar/ufCalendar.ics&limit=8&gmt_end=' . gmmktime(23, 59, 59));

Leave a Reply