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: email@example.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.
- 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.