5 May 2006
Today, you get a little how to for creating iCal compatible calendars from Textpattern. This is most useful if you use Textpattern to store events, and really useful if you use it to store gigs in, like The Rogers Sisters Website does. The following requires a bit of textpattern knowledge (of various txp: tags and the like), but I’m going to try and make it as clear as possible.
Just for a bit of background, the gigs on the Rogers Sisters site are stored as articles in a section called “gigs”, with the venue and place as the article title, any further description (like who’s supporting) in the body, and the gig date as the posted date.
Then to display the gigs you simply use an article_custom tag, with the date set to future like this:
<txp:article_custom form="gig" time="future" section="gigs" sortdir="asc" limit="25" />
Now, on to the calendar! To start with, the file format that iCal uses is called .ics, and is used by several other calendar programs so hopefully this should work with any .ics compatible program. The key piece of information that makes this all fairly straightforward is that .ics is a text based format, and a fairly simple one at that, so we can output a page from textpattern that complies to the .ics format, and can hence be used in iCal.
First, set up a new section in Textpattern (in presentation -> sections) – I called mine “gigcalendar”, and make it use a new blank page by creating a new page in the pages tab, and then setting the section to use it.
Next, copy the code below into the blank page (making sure you don’t have anything else, including any html, on the page):
PRODID:-//Apple Computer, Inc//iCal 1.5//EN
<txp:article_custom form="gigsicsitem" time="any" section="gigs" sortdir="asc" limit="10000"/>
Now, what this does it output the required .ics header and footer and then get the gigs we want to show up in the calendar (we’re after both past and future gigs, hence the
time=”any”), using the “gigsicsitem” article form, which is what outputs each event.
Next, go over to the forms tab and create a new article form (what I’ve called ‘gigsicsitem’), and past in the code below:
DTSTART:<txp:posted format="%Y%m%d" />T193000
DTEND:<txp:posted format="%Y%m%d" />T230000
This simply outputs each event in the correct formatting for .ics use. The DTSTART and DTEND are probably the only things that need explaining. These are the start and end times of the event, the first part of which is the date in yyyymmdd format, which we create using the “format” argument of the txp:posted tag. The second part is the exact time of the event (hence it starting with “T”). As we’re dealing with gigs, I’ve made some assumptions as most gigs start at 19:30ish and end at 23:00, so I’ve hard coded the times in. You could, however, quite easily use different formatting on the txp:posted tag to get the posted time as well. To make the end date you could always use a custom field as well, as textpattern only has one date field.
After you’ve done all that, your “gigscalendar” section should be outputting a valid .ics file, so simply take the url ( e.g. http://www.yoursite.com/gigscalendar ) and in iCal under the “Calendar” menu, click the “Subscribe…” menu item and enter the address.
That’s it! Hope this might be useful to someone out there…
I remember having a conversation with a manager a few years back. It wasn’t an easy meeting. Throughout he was leaning forward in his seat, rocking slightly back and forth, his dissatisfaction with the situation physically manifesting with every sentence.
We’d already talked about the problem at length, tried several different...
When I started my career in music I worked in what was then known as the New Media department. “This new internet malarkey” we collectively thought “is probably something we should pay attention to. Let’s separate out the people that seem to understand what it is hope they don’t cause...
Last week a new band came in to play us their freshly delivered debut album. There is protocol in these situations. Everyone must sit in rapturous contemplation and laser focused attention. Heads must bob. Feet must tap. After every track you must make some gesture that indicates that, yes, that...
Let’s take stock, shall we? By all accounts, the world has gone crazy. Not as bad as when it’s been really bad, but, you know, bad. Facts are dead. It is entirely possible that some people genuinely think up is actually down, and to say anything different is unpatriotic. In...
I was talking recently with someone I know who works at a music media company. I say “media company” both to be purposefully vague but also because I struggle to think of a better term that encompasses the merging worlds of distribution, retail and promotion.
Day in, day out, they get...