HOSTBABY HELP CENTER

Calendar Tips

Calendar RSS

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>';

?>

Show Past Dates - Variations

If you enable the "Show Old Events" option on your /hostbaby -> options/preferences page, you'll notice right away that it shows all your past dates *above* your upcoming dates, which may not be what you want.

There is a fairly easy way to show show your "past" dates either below your upcoming ones, or on their own separate page.. and it's called the show_calendar_past_dates() function.

The quick way to 'fix' this for people is first *turn off* the 'Show old events' option on their /hostbaby, then make a copy of their current calendar page, name it something like calendar-past.html (or whatever) and change basically one line:

<? show_calendar($my_artist_code) ?>

to:

<? show_calendar_past_dates($my_artist_code) ?>

That's pretty much all you need. Of course you may also want to change the title/header of the page to indicate these are past dates, and maybe also add a link back to your main calendar page. You'll also of course want to add a link somewhere else on your site (most probably the main calendar page) to this new "past dates" page, so people can actually find it.

You can also easily add your past dates at the bottom of your current calendar page.. just put in a few lines after the show_calendar() line:

<h2>Past Shows</h2> 
<? show_calendar_past_dates("artistcode") ?>

Obviously your mileage will vary, depending on how much customization you've already done on your calendar, and/or how familiar you are with PHP. If you're having any trouble getting this going on your site, you can always feel free to shoot us an email and we'll help you get it working (try and be as specific as possible with what you want to do).

Calendar Function Definitions

These are the function definitions we currently have for the calendar:

show_calendar($artistcode, $template = '')'''
show_calendar_next_date($artistcode, $template = '', $num_of_dates = 1)
show_calendar_past_dates($artistcode, $template = '', $num_of_dates = 0)
show_calendar_artist_name($artistcode)

An example way to "call" one of these functions would be:

show_calendar_next_date($my_artist_code, '', 3);
// (this shows your next 3 upcoming dates, with no template)
show_calendar_next_date($my_artist_code);
// (shows only the next upcoming date)

Using the template allows you to completely change the look of the output of the functions. Which i might as well explain here.

That second template argument will be a filename, 'calendar.php' for example. Inside this file, which you would create/edit/upload yourself, you would have the code that displays each individual date based on our variable names. Here's the default template for the calendar:

<?php

if ($event_date == date('Y-m-d')) {
    print ' <table border="0" class="calendar_today"><tr><td class="calendar_today">';
} else {
    print ' <table border="0" class="' . $swtch . calendar_event_'"><tr><td class="' . $swtch . calendar_event_'">';
}
if ($event_date != '0000-00-00') {
    print "\n".'  <table border="0" width="100%" class="calendar_date_table"><tr>' .
          '<td class="calendar_date_text" nowrap="nowrap">'.
           date($dateformat_new, strtotime($event_date.' '.$event_time))."<br /></td></tr></table>\n";
}
if (isset($event_title) && !empty($event_title)) {
    print '  <span class="calendar_event_title_text">' . $event_title . "</span><br>\n";
}
print '  <span class="calendar_venue_text">';
if (isset($venue) && !empty($venue)) {
    print '<span class="calendar_venue_name">' . $venue . '</span><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 />';
}
print "</span>\n";
if (isset($notes) && !empty($notes)) {
    print '  <span class="calendar_notes_text">'.nl2br(link_urls($notes))."</span>\n";
}
print " </td></tr></table>\n\n";

?>

If you copy+pasted this into a calendar.php file, these two functions calls would display the same thing:

show_calendar($my_artist_code);
show_calendar($my_artist_code, 'calendar.php');

Only with the second one, you can go into your calendar.php and edit it to behave exactly how you want (change the tables, take out the style sheets, etc).

Actually, to get the page to look *exactly* the same, you'll need to surround your show_calendar call with a table, because these lines don't get outputted when you're using a template:

<table border="0" class="calendar_main"><tr><td class="calendar">
<?php show_calendar($my_artist_code, 'calendar.php'); ?>
</td></tr></table>

The table can be changed to a

<div class="calendar">

, or you can not use the ".calendar" CSS definition and you wouldn't need this, etc, etc.

you want it in the same directory as your calendar file (the one with the function call). if you happen to see this error:

"Parse error: parse error, unexpected T_STRING in /usr/local/www/hostbaby/hostbaby.php"

This seems to happen to everyone who copy+pastes code from this forum into their Mac TextEdit. It basically replaces the indenting with some weird hidden characters that mess up the PHP parser on the server. If you go back into the file and remove and/or replace the indenting (aka all the spaces or tabs at the beginning of any of the lines), then re-upload, it should be ok.

Have more questions? Submit a request