HOSTBABY HELP CENTER

Calendar RSS feed

Calendar RSS feed

 

Here's a quick way to get an RSS feed for your calendar.

You'll want to create two new *text* files, one for the RSS feed itself and one for the calendar template we'll be using to format it. In this example, i'm going to use "calrss.php" for the feed and "calrss-template.php" as the template file (you can name them whatever you want, but note the show_calendar() line in the first file needs to point to the exact template filename for this to work). There's also *5* variables at the top here you'll need to change:


calrss.php:

<?php

$site_title = "My Site's Name";
$site_url = "http://www.mydomain.com";

$feed_description = "Concert Calendar";
$calendar_url = "http://www.mydomain.com/calendar.html";

$my_artist_code = "calendarartistcode";

require 'hostbaby';
header('Content-type: text/xml');

print '<?xml version="1.0" encoding="iso-8859-1"?>' .
      '<rss version="2.0">' .
       '<channel>' .
        '<title>' . $site_title . '</title>' .
        '<link>' . $site_url . '</link>' .
        '<description>' . $feed_description . '</description>';

show_calendar($my_artist_code, 'calrss-template.php', 10);

print '</channel></rss>';

?>

 

calrss-template.php:
<?php

global $calendar_url;

print '<item>' .
       '<title><![CDATA[' . date('M j Y', strtotime($event_date.' '.$event_time)) . " - $event_title - $city, $state]]></title>" .
       '<link>' . $calendar_url . '</link>' .
       '<guid>' . $calendar_url . '?id=' . $id . '#' . date('Y-m', strtotime($event_date)) . '</guid>' .
       '<description><![CDATA[';

print '<b>' . date($dateformat_new, strtotime($event_date.' '.$event_time)) . '</b><br />';

if (isset($event_title) && !empty($event_title)) {
    print "<b>$event_title</b><br />";
}
if (isset($venue) && !empty($venue)) {
    print "$venue<br />";
}
if (isset($address) && !empty($address)) {
    print $address . '<br />';
}
if (isset($city) && !empty($city)) {
    print $city;
    if (isset($state) && !empty($state)) {
        print ', ';
    }
}
if (isset($state) && !empty($state)) {
    print $state;
}
if (isset($zip) && !empty($zip)) {
    print ' ' . $zip;
}
if ((isset($state) && !empty($state)) || (isset($city) && !empty($city)) || (isset($zip) && !empty($zip))) {
    print '<br />';
}
if (isset($country) && !empty($country)) {
    print $country.'<br />';
}
if (isset($phone) && !empty($phone)) {
    print $phone.'<br />';
}
if (isset($venue_url) && !empty($venue_url) && ($venue_url != 'http://')) {
    print '<a target="_blank" href="' . (substr($venue_url,0,4)=='www.' ? 'http://' : '') . $venue_url . '">' . $venue_url . '</a><br />';
}
if (isset($price) && !empty($price) && ($price != '$')) {
    print 'Price: '.$price.'<br />';
}
if (isset($notes) && !empty($notes)) {
    print link_urls($notes);
}

print ']]></description></item>';

?>
Have more questions? Submit a request