I am using an api from a third party developer that I can get to work outside of EE with a simple PHP include, but I can't seem to get it to work within a template.
You will see that this page (outside of EE) works and lists the events: http://discoverycolorado.dreamhosters.com/public_calendar_listing/
Here is the page where it is not working: http://discoverycolorado.dreamhosters.com/events
I don't think this is an API, I think it may be an EE issue or something I am not doing correctly with the PHP include. I was wondering if someone might have an idea why this might not be working?
Here is the include on the page I am trying to get this events list to show:
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/public_calendar_listing/event_search_list.php";
include_once($path);
?>
Here is the file I am including on the above page:
<?php $count = 0; ?>
<table>
<tbody>
<?php foreach ( $events as $event ) {
// If there was a search, and nothing matched, return nothing
if ($q && $event['search'] == '0') {
} else {
// Bring the recurring event dates back in to merge
if (is_array($dup_events)) {
foreach ($dup_events as $dup_event) {
if ($event['id'] == $dup_event['id']) {
if ($event['date'] !== $dup_event['date']) {
$event['end_date'] = $dup_event['date'];
}
}
}
}
########################################
#### Format the time and datestamps ####
########################################
$start_stamp = strtotime($event['start_time']);
$end_stamp = strtotime($event['end_time']);
$date_stamp = strtotime($event['date']);
if ($event['end_date']) $end_date_stamp = strtotime($event['end_date']);
if (date('i', $start_stamp) !== '00' ) {
$event['start_time'] = date($config['timeformat'], $start_stamp);
} else {
$event['start_time'] = date($config['timeformat_simplified'], $start_stamp);
}
if (date('i', $end_stamp) !== '00' ) {
$event['end_time'] = date($config['timeformat'], $end_stamp);
} else {
$event['end_time'] = date($config['timeformat_simplified'], $end_stamp);
}
if ($event['end_date']) {
if (date('F', $end_date_stamp) == date('F', $date_stamp)) {
$event['end_date'] = date($config['dateformat_simplified'], $end_date_stamp);
} else $event['end_date'] = date($config['dateformat'], $end_date_stamp);
$event['date'] = date($config['dateformat'], $date_stamp);
} else $event['date'] = date($config['dateformat_single'], $date_stamp);
$event['occur'] = date('Ymd', $date_stamp);
?>
<tr><td>
<?php if ($config['display_ccblink']) { ?>
<a href="https://<?php echo $config['url'] . '/event_detail.php?event_id=' . $event['id'] . '&occur=' . $event['occur']; ?>" target="_blank">
<strong><?php echo $event['name']; ?></strong></a>
<?php } else { ?>
<strong><?php echo $event['name']; ?></strong>
<?php } ?>
</td></tr>
<tr><td>Date: <?php echo $event['date'];
if ($event['end_date']) {
echo ' - ' . $event['end_date'];
} ?></td></tr>
<?php if ( $event['start_time'] !== '12' ) { ?>
<tr><td>Time: <?php echo $event['start_time'] . ' - ' . $event['end_time']; ?>
<?php if ( $event['location'] ) { ?>
<?php echo ' (' . $event['location'] . ')'; ?></td></tr>
<?php } ?>
<?php } else { ?>
<tr><td>Time: <?php echo $event['start_time']; ?>
<?php if ( $event['location'] ) { ?>
<?php echo ' (' . $event['location'] . ')'; ?></td></tr>
<?php } ?>
<?php } ?>
<?php if ( $event['description'] ) { ?>
<tr><td style="white-space:pre-wrap;">Description: <?php echo $event['description']; ?></td></tr>
<?php } ?>
<?php if ($config['display_contact']) { ?>
<tr><td>Contact: <a onclick="javascript:window.open('https://<?php echo $config['url']; ?>/app/easy_email.php?ax=create_new&individual_id=<?php echo $event['leader_id']; ?>&event_id=<?php echo $event['id']; ?>&individual_full_name=<?php echo $event['leader']; ?>','Email','scrollbars=1,width=520,height=710');return false;" href="javascript:void();" ><?php echo $event['leader']; ?></a> <?php echo $event['leader_phone']; ?></td></tr>
<?php } ?>
<?php // 2014/02/14 mjf include group name ?>
<?php if ($event['group_name']) { ?>
<tr><td><i><?php echo $event['group_name'] ?></i></td></tr>
<?php } ?>
<tr><td> </td></tr>
<?php $count++;
}
} // end foreach $event ?>
</tbody>
</table>
<?php if ($count == 0) { ?>
<p> No results found. </p>
<?php }
?>
Here is config file for the api:
##################################################
#### CCB PUBLIC CALENDAR IN LIST FORMAT ####
#### Configuration Options ####
#### ####
#### This CCB API example provided by: ####
#### Philip Cain <[email protected]> ####
##################################################
$config = array (
#### CCB API CONFIG ####
// Your church's CCB address (no "http://" or trailing "/")
'url' => 'xxxxxxxx',
// API username and password. You can create one by following the instructions here:
// https://churchcommunity.fogbugz.com/default.asp?W490
//
// Make sure you enable the "public_calendar_listing" service
'username' => 'xxxxxxxx',
'password' => 'xxxxxxx',
#### OPTIONS ####
// Create a link to the event in CCB
'display_ccblink' => true,
// Display event contact information
'display_contact' => true,
// Display recurring or multi-day events as a single event?
'combine_recurring' => true,
// Set the range for how far into the future you'd like to look
'range' => '+3 months',
// 2014/02/14 mjf specify groups to include in calendar
// group names must match ccb group names exactly
// to provide no filtering, use:
// 'groups' => array(),
// to filter for Congregational Life Events and AWANA events, use:
// 'groups' => array('Congregational Life Events', 'AWANA'),
'groups' => array(),
#### DATE/TIME FORMATS ####
// Main time format (default looks like "6:30am")
'timeformat' => 'g:ia',
// Simplified time format, used when the time is at the top of the hour (default looks like "6am")
'timeformat_simplified' => 'ga',
// Main date format (default looks like "May 18")
'dateformat' => 'F j',
// Date format for one day events (default looks like "Wednesday, May 18")
'dateformat_single' => 'l, F j',
// Simplified date format, used for the end date of a multi-day event (default looks like "18")
'dateformat_simplified' => 'j',
);
?>