Calendar Function Definitions

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)

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)
// (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:


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="calendar_event_' . $swtch . '"><tr><td class="calendar_event_' . $swtch . '">';
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, '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'); ?>
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