I’ve been working with well known LibDem blogger Mark Pack, whose day job is with PR company Mandate, to migrate the website of the Cancer Campaigning Group over to WordPress. It’s a fairly modest little site, and I was under orders to keep the design broadly as-was. But it’s got one specific feature I’m very excited about.
Nearly four years ago, I wrote about the increasing adoption of the iCal standard for calendar sharing. With Outlook 2007 set to embrace the format, I foresaw a rush of websites publishing event data in iCal feeds, allowing you to subscribe with a single click, and then see someone else’s dates alongside your own.
The, ahem, optimistic assessment would be that I was well ahead of the curve. Four years on, you’ll struggle to find many (mainstream) sites offering such feeds – although I’ve noticed a slight increase of late. The BBC, for example, had a feed of World Cup fixtures; the Arsenal site has a similar service for its new fixture lists, including the Reserves, Youth and Ladies teams. Why? Maybe it’s the growing prevalence of smartphones by Apple and Google, both of whom were quick to adopt the format.
And then suddenly, the opportunity presented itself to build an iCal-enabled site of my own. The Cancer Campaigning Group’s previous site had an ‘events’ section, although it wasn’t anything special. WordPress 3.0, released just over a month ago, includes the ability to create ‘custom post types’; and I only recently discovered its little-documented ‘add_feed’ function, introduced as far back as early 2007. A little jQuery on the front- and back-ends, and we had all the ingredients we’d need.
So I’ve written some code to create a custom post type called ‘Event’, and added it into the WP back-end interface. You enter event details just as you would enter a post or page, with a title, body text and optional excerpt. There’s a special ‘event type’ categorisation; and a pop-up date picker for simplicity and consistency.
Then to call the calendar into a page, you use a WordPress shortcode – [calendar]. You can also specify the range (past or future), and the view (simple text list or javascript-enabled grid), plus the ‘type’ (if you’re using them). This actually gives you remarkable flexibility, only some of which is obvious on the Cancer Campaigning Group site.
And of course – there’s the iCal feed. If you take the feed URL into your calendar app of choice, you should be able to subscribe to it. And then, as the site admin adds new events, these will simply appear alongside your own personal appointments.
It hasn’t been easy: and to be honest, I’m not entirely confident that we’ve captured and resolved all possible issues. The biggest problem has actually been with Google Calendar: Google caches the feeds for an indeterminate period, and there’s no apparent way to force a refresh. So if there’s an issue with your code, you may not realise for several hours; and it may take a further few hours for your fix to feed through. I’m also fairly sure that the code, as it currently stands, won’t scale too well.
So for now, I’m watching the Cancer Campaigning Group site to see what happens. If it goes OK, I’ve got a couple of much higher-profile clients waiting in the wings.
Responses
Why not just use hCalendar (set of agreed HTML class names) in your markup, which then allows browser tools, third-party converters, or even scripts running on you own server, to extract iCal events or feeds.
Oops: forgot the URL: http://microformats.org/wik/hcalendar
Do you have any plans to release the code that creates this or a tutorial for people to create their own. Looks really swish from the screenshots and sounds like a very useful addition to WordPress.
Ditto to Chris’ comment!
Andy – I do need to go back and div-up the text output a little better, and you’re right, I probably should use the hCal classes for that. But that wouldn’t be a substitute for a proper iCal feed. Microformats haven’t exactly taken off as one might have hoped.
Chris & Ben – no plans to release it in the imminent future, I’m afraid. Partly because I’m about to close the shop for a month, and partly because I know there are aspects which need further attention.
Simon – this is exactly the kind of thing I’ve been looking for for southlondonpost.com. I’ve been using Google Calendar to try and generate an online list of events which is shareable, and it’s eminently unsatisfactory. Hope you do get around to releasing this into the wild at some point.
There are billions of published microformats – how many more do you want? There are tools now for all of the popular browsers; and microformats – including hCalendar – are recognised by Google.
If you add the right code to your page/ server, they will not be a /substitute/ for an iCal feed – they will /generate/ an iCal feed.