God isn't bland. The Church shouldn't be, either.
Google Calendar on Your Site: Part Two (ExpressionEngine)

Because a lot of this stuff is magic to me, I asked Wes Plunk to write today’s post.  Wes works for LifeWay Christian Resources, and is a web programmer extraordinaire.  He recently helped with the launch of Chapel.org.  If you have questions this overview doesn’t answer, feel free to email him: mediasalt@wesandemily.com.

The challenge was on when Cleve said he needed events on the new Chapel.org.

Well, I’ve never known a challenge I wasn’t up for, so I had to find just the right solution that would solve all the problems that you traditionally have with multi-site church calendars. We also had to create an interface that everyone could easily use, and with great flexibility.

I’ve fallen head over heels for anything with the word Google on it, so the choice was easy. Google Calendar!

This solution still posed several issues. I’ll dissect all of these below and explain exactly how we overcame them.

Google Limitations

  • Tagging or categorizing events is not currently supported via the interface.
  • Custom event fields are available through the API but not visible, and cannot be managed in the public calendar interface.

Challenges and Solutions

Setup calendar with categories on Google

Since Google doesn’t support tagging and/or event categories, we had to set up a calendar for each category combination that we wanted to view on the site. This seems like quite a bit of work, but in the end it offers the most flexibility when editing permissions — customizing who has access to edit any of those different groupings of events.

Examples of the calendar list:

  • Barrington – Campus Events
  • Barrington – Compassion
  • Barrington – Kids
  • Grayslake – Compassion
  • Grayslake – Small Groups

Import events into ExpressionEngine database

This was definitely the most challenging, but Google and Zend have already done some really nice work, and I take no credit on the core of how this works. I basically put together some pieces of the puzzle that best fits the needs of Chapel.org with ExpressionEngine.

Here are the tools I used in order of how they were used.

  • Google API: This is a great API (could use a bit more docs) that allows for almost anything to be done to any calendar. From login to log out you can accomplish it with this web service API.
  • Zend PHP GData library: This library provides simple and easy objects that can be used in PHP to hit the Google API without having to write all the web service calls.
  • Custom Google API Module (simplified chapel.org event feed and account management in the ee admin): [CLICK HERE for a full details  and sample code]
  • An enhanced version of XMLGrab: XMLGrab lacked the ability to update existing entries so I had to add the update capabilities. I also moved the category inserts so it runs for both additions and updates and cleans out the previous assignments first. Finally, I expanded the category attributes to the tag so you can add categories from multiple locations in the xml, and expanded the insert and update of date fields so that they get added to ee with a fixed UTC timezone. This could certainly be pushed out to the tag, and would allow for more customized solutions.
  • Cron Job: I added cron job to host the account that runs the url of the template containing the XMLGrab tag. The XMLGrab tag has a url attribute of the template that contains the Custom Google API Module tag. Custom Google API Module tag has a account attribute that contains the alias to the account in the module table which allows the module to login and build the xml.

Sync events with Categories

The XMLGrab wipes out and reloads all categories every time it inserts/updates events in the ExpressionEngine weblog. All new categories are added during this process. However, because of a bug (which I’ve yet to successfully track down) these new event categories will not show up correctly using the weblog module tags in my templates.

In order to avoid this issue:

  • I preload ExpressionEngine with all the categories I know of.
  • I allow XMLGrab to do the inserts anyway (should be rare if ever).
  • During the insert I send an email to myself explaining what category was added.
  • I manually delete and re-add the new category using the ExpressionEngine admin interface.
  • I manually re-run the XMLGrab job.

Allow custom fields for events within Expression Engine

This has not been implemented, but you’ll notice it will be rather easy to do when the time comes.

  • Create a second weblog for the EE Event Info.
  • Add the fields you’d like to have available for each event.
  • Use the Playa Field Type to allow multiple events to this metadata entry.
Share on TwitterShare on TumblrShare via email


  1. Benjamin Dickie (Reply) on November 3rd, 2009

    HI, love your website. You have great content on here.

    I came across this URL after doing a search on twitter for ‘Google Calendar’ as I wanted to see what conversations were taking place on that service.

    Our calendar at http://www.calendarcompanion.com was built with churches and large clubs/organizations in mind as we have a plethora of customizable features that bring a huge value add to the entire church body. The calendar can be framed within your existing site and is super easy to use. Just thought you might want to take a look at this and it could be a solution for your church or other churches to run with!

    God Bless,

    Benjamin Dickie

  2. Adrienne Travis (Reply) on November 3rd, 2009

    Are you going to release a patch or diff for XMLGrab? Because i would TOTALLY love the ability to do updates.

  3. Peter (Reply) on December 2nd, 2010

    HI!,

    We have been searching for a solution to our problem of displaying the Google calendar – without looking like one! and your solution looks like something that might help :)

    I am not a coder and have someone else working on this but…..

    1. Are you able to display events in the same view/ format as Google (agenda, week, month view) rather than just a list?
    2. Can you also select multiple categories rather than just one and therefore without also having to reload the page each time?

    Any help appreciated. We want to display charity events and community events and use Google to collect the feeds.

    many thanks,

    Peter


Connect with Facebook