Integrating and maintaining a calendar of events within the Symphony CMS

Stamped: 03 May 2011 | Show comments

Calendar XSLT Utility

Symphony doesn't easily offer a way to integrate a calendar of events into an existing setup, so I've come up with an XSLT Utility to make it a little easier.

After having to revisit a calendar of events and kind of hacking my way through it originally, I've come up with another way to incorporate an event calendar more easily into an existing site. A very simple example is hosted here. The source is available at github. If you have any issues, please discuss them at github or at the Symphony forums: http://symphony-cms.com/discuss/thread/66262/.

Requirements:

  1. Nils' Date and Time Field Extension - Because it uses a nice interface and allows for easier management of events; make sure to take the experimental branch.
  2. This event I created, found on github, placed in your workspace/events folder.
  3. A section to handle all the events with a single Date & Time field, it must contain at least one other field, like name, description, etc. But you can have as many as you like. They will all be displayed, and can be disabled by using CSS display:none; on the <li>. For example, if we had a field called description it would be produced as <li class="description">, so .description { display: none; } would get rid of it.
  4. Attach the event to whatever page you want to display the calendar on.
  5. Attach a data-source pulling whatever events you wish, you can limit it by date to reduce the amount of entries, but do not change the grouping.
  6. Finally, in the page you wish to drop the calendar in, the php xmlns must be added to the <stylesheet> tag, and the function to generate the calendar must be used. An example page would look like is below. The second parameter next to the function is the name of the data source. The third is an optional path to link to the event by id so you provide the root path (if none is provided it will just be listed as text). The fourth is an optional class to provide the table with, the default is calendar.
      <?xml version="1.0" encoding="UTF-8"?>
        <xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:php="http://php.net/xsl">

        <xsl:import href="../utilities/master.xsl"/>

        <xsl:template match="/data">

        <h1><xsl:value-of select="$page-title"/></h1>
        <xsl:value-of select="php:function('generate_calendar', 
          calendar-main-events, concat($root,'/calendar/event'), 
          'calendar')" disable-output-escaping="yes"/><br />
        </xsl:template>
        </xsl:stylesheet>

Bugs/features:

  1. It's not possible to have a date field in the same section you plan to use for the events, it conflicts with a date time field.
  2. If you have two calendars on the same page, when you switch months/years, it will switch them on both calendars.

You can download it at my Github repo.

tags: symphony, symphony extension, portfolio
recent entries
Rails — A faster way for next and previous links on a post, article, or any model
The awkward things Siri says
Node.js — Getting oAuth Up and Running Using Express.js and Mongoose
Node.js — Getting oAuth Up and Running Using Express.js, Railway.js and Mongoose
Migrating from Rails 3.1 RC4 to RC5 using Heroku's Cedar Stack (also compass, unicorn, and sendgrid)
Random Freeze Fix for GTX 460 in 10.6 (osx86)
Wasted on Steam - an analytic tool for the Steam platform
Rails 3.1 — SQL logging to STDOUT during testing (with rspec, test::unit, or cucumber)
Rails 3.1 — Using ERB/HAML/etc within a Coffeescript JS file
Rails 3.1 — 'load_missing_contant': Expected ... to define ... (LoadError)
View the entire archive of articles