Four score and seven years ago… ok, maybe not that long ago. 🙂
Maybe it was a year or two ago that I published how to retrieve and customize a public web calendar for your church using CCB’s API.
As with most of CCB, some of the native functionality leaves a church desiring more in the area of visual appeal.
So just as we did with the public web calendar tutorial, today’s tutorial will tackle how to retrieve and customize calendar listings for individuals.
Today’s tutorial will come in handy if you have a church app that seeks to provide attendees and members with the capability of seeing a list of events based on their respective CCB profile id.
For play by play details, do take time to read and review the public web calendar tutorial. The code below is a modified version of the public web calendar tutorial’s codebase.
Of course, there are some glaring differences to the code base that you’ll need to pay close attention too:
- apiService variable should be set equal to individual_calendar_listing
- startDate and endDate variables are required and should be set to respective dates using YYYY-MM-DD date format
- the XPATH query should be defined as //item instead of //items/item
When using CCB API to access the individual_calendar_listing web service, the following attributes (see CCB Documentation) are available for retrieval should data exist:
- date – the event date (datetime format of YYYY-MM-DD)
- event_name – the event name
- event ccb_id – the event id
- event_description – the event description
- start_time – the event start time (00:00:00 military format)
- end_time – the event end time (00:00:00 military format)
- event_duration – the event duration in minutes
- location – the event location
- group_name – the group name associated with event
- group ccb_id – the group id associated with event
- group_type – the type of group
- grouping_name – the designated group name to be shown
- leader_name – the leader name
- leader ccb_id = the leader id
- leader_phone = the leader phone number
- leader_email = the leader email address
If you desire additional event information, then you’ll have to use the event id and pass it to the event_profile web service.
If the event has a registration form that you’re wanting to post a link to, then simply append the event’s id or place the correct form link with the appropriate form id attached.
To begin this tutorial, open the text editor of your choice, and name and save the following php file: person-calendar.php.
Copy, paste, and save the code below, ensuring you change the id, startDate, and endDate variables to their respective values.
// contains resusable globals and functions
$apiService = 'individual_calendar_listing'; // CCB api service
$id = '2';
$startDate = '2018-02-01';
$endDate = '2018-02-28';
$urlData = array_filter( array(
'srv' => "$apiService",
'id' => "$id",
'date_start' => "$startDate",
'date_end' => "$endDate"
$rss = ccbDetails('get',$urlData); // transform to XML
$nodes = $rss->xpath('//item'); // xpath for item
$response_object = '<h1>Public Calendar Listings</h1>';
foreach ($nodes as $node)
// now print the calendar details for each item
// (See CCB API documentation for more $apiService fields)
$response_object .= '<h2>'.$node->event_name.'</h2>';
$response_object .= '<p>'.$node->event_description.'</p>';
$response_object .= '<p>'.$node->location.'</p>';
$response_object .= '<p>Date: '.$node->date.' | Start Time: '.$node->start_time.' | End Time: '.$node->end_time.' | Duration: '.$node->end_duration.'</p>';
$response_object .= '<p>Group Name: '.$node->group_name.'</p>';
$response_object .= '<p>Group Type: '.$node->group_type.'</p>';
$response_object .= '<p>Grouping Name: '.$node->grouping_name.'</p>';
$response_object .= '<p>For more information, contact '.$node->leader_name.' via <a href="mailto:'.$node->leader_email.'">email</a>';
$response_object .= ' or call '.$node->leader_phone;
$response_object .= '.</p>';
Now you’re ready to open the person-calendar.php in a web browser to test your technical prowess. If successful, then your browser should display information as shown in the example image below.
That’s it for this tutorial. Let me know if you have any technical issues, challenges, questions or comments. See you back here next week! 😉