This weekend I was working on some SFU community sites and I decided it would be nice to display the SFU ULife calendar on one website in particular. SFU ULife is a community building initiative which aims to increase the visibility of the community and events at SFU in a pledge to increase student involvement and awareness. Read more about ULife’s goals Here.
As part of this initiative ULife maintains an events calendar that is available both in HTML and RSS formats. I was much more interested in the RSS feed as it can be easily parsed and manipulated by server-side PHP.
How The Refactor Works (In A Nutshell)
The basic operation of the script is very straight-forward.
- A copy of the ULife calendar RSS feed is downloaded and cached from https://events.sfu.ca/rss/calendar_id/3.xml.
- The RSS feed is parsed by a slightly modified version of Last RSS which converts the feed into PHP associative arrays.
- The arrays are then passed to the Smarty Template Engine which makes the output look all pretty
Simple eh? There is a little bit more of business logic, as the user is able to specify the template file to use, the CSS file to use, the number of days to display as well as indicate if the script is to output a full HTML page or just the HTML code needed for the calendar.
Right now there is only a single template available – a vertically aligned one, and a single style – a dark one. Users of the script can of course come up with their own style-sheets by simply downloading and editing the dark style sheet to their liking. If there is demand for it, I will write more templates, starting with a horizontally aligned template, along with a couple more style sheets.
To play around with the Calendar Refactor take a look at http://ulife.dustint.com