Quick-n-Dirty templates for the Calendar Module which outputs a basic RSS 2.0 feed, which can then be reused on other sites or subscribed to by site visitors.
This is my first draft, there's bound to be a problem somewhere

The goal is to have a single Calendar instance which can share its event listings with multiple CMSMS installations.
RSS feeds are a natural extension of a calendar system; am a bit surprised and puzzled at the lack of such a feature in anything available for CMSMS.
Step 1. Create a new CMSMS page template, CalendarRSS20, which contains the following:
Code: Select all
<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>{sitename} Events</title>
<link>{root_url}</link>
<description>Events scheduled on the {sitename} calendar</description>
<language>en-us</language>
<pubDate>{modified_date format="%A, %d %b %Y %H:%M:%S %z"}</pubDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
{content}
</channel>
</rss>
Step 2. Create a new Calendar module template, CalendarRSSfeed, which contains the following:
Code: Select all
{foreach from=$events key=key item=event}
{if $event.event_date_start ne ''}
{assign var=rssStartDate value=$event.event_date_start|date_format:"%D"}{* editable date format *}
{else}
{assign var=rssStartDate value=''}
{/if}
{if $event.event_date_end|date_format:"%Y%m%d" gt $event.event_date_start|date_format:"%Y%m%d"}{* dont edit these formats *}
{assign var=rssEndDate value=$event.event_date_end|date_format:"%D"}{* editable date format *}
{else}
{assign var=rssEndDate value=''}
{/if}
{if $event.event_summary ne ''}
{assign var=rssEventSummary value=$event.event_summary|escape:'html'}
{elseif $event.event_details ne''}
{assign var=rssEventSummary value=$event.event_details|escape:'html'}
{else}
{assign var=rssEventSummary value=''}
{/if}
<item>
<title>{$event.event_title}</title>
<link>{$event.url}</link>
<description>{if $rssStartDate ne ''}<div class="calendar-rss-date">{$rssStartDate}{if $rssEndDate ne ''} {$lang.to} {$rssEndDate}{/if}</div>{/if}{if $rssEventSummary ne ''}<div class="calendar-rss-summary">{$rssEventSummary}</div>{/if}</description>
<guid isPermaLink="true">{$event.url}</guid>
</item>
{/foreach}
Step 3. Create a new page that uses the above page template (Step 1), aliased as "events-rss", which contains the following content:
Code: Select all
{cms_module module='Calendar' display='upcominglist' dbupcominglisttemplate='CalendarRSSfeed' limit='25'}
Step 4. If you are publishing the RSS feed on a web site, you can use the two classes in the output to help style the event listings using CSS: calendar-rss-date and calendar-rss-summary. The item description output is simply:
Code: Select all
<div class="calendar-rss-date">[[DATE]]</div><div class="calendar-rss-summary">[[SUMMARY]]</div>
where [[SUMMARY]] is either the event summary or event details (if summary field is empty)
and if either [[DATE]] or [[SUMMARY]] would be empty, that entire container is omitted from the output for that event.
It would be up to your RSS import module or script to assign a class or tag to item titles and to wrap entire items around a container for styling purposes.
Notes: Cannot do anything here about the HTML comments appended to the end of pages (including the feed output by the above) by CMSMS. Those comments are added after-the-fact by CMSMS's index.php.
Unless you keep the feed page's entry in the menu or link to it some other way, no one will know it exists, which may or may not be the desired setup. If you want a visitor's browser to 'autodiscover' the feed, add a line to your site's metadata; perhaps something like this:
Code: Select all
<link rel="alternate" type="application/rss+xml" title="{sitename} Event Calendar Feed" href="{cms_selflink href='events-rss'}" />
If you improve upon this, please reply to this post and share your goodies.

EOF 05JUN08/2000CST
EDIT 06JUN08/0305CST - fixed a typo in a calendar template variable
EDIT 09JUN08/1115CST - fixed closing div tags in calendar template output
(the attachment is a text file version of this post)