Last updated November 20, 2011. Created by Se7enLC on October 22, 2008.
Edited by KarenS, LeeHunter. Log in to edit this page.
GCal Events is a module which will display upcoming events in a block. The source for these events is a Google Calendar.
Who is this module for?
- If you want to simply and easily add a calendar to your Drupal site with minimal effort, this module is for you.
- If you already have a Google Calendar for your organization and want professional-looking integration
How does it work?
GCal Events subscribes to your Google Calendar's XML feed. It uses SimplePie to cache and parse the XML to get the title, location, date, time, and description from the event. These data fields are displayed in a Drupal block.
FAQs
- Why not use an iCal parser? Good question. iCal is a very complicated format which can handle a lot of complicated scheduling information (repeating/recurring events, etc). As popular as the iCal format is, there are very few iCal parsers available, and none that I could find that met the requirements for this module. That would make for an excellent extension to this module, however.
- Why do I need to download simplepie.inc? SimplePie is a separate project that GCal Events uses to cache and parse XML feeds. SimplePie is released under the BSD License, rather than the GNU Public License that Drupal is licensed with.
Features
Here are some of the interesting features built into GCal Events:
- Can read from public or private google calendar
- Multiple blocks can be set up, each configured independently.
- Date/Time display format can be configured
- Timezone can be configured (PHP 5.1 and higher)
- Display uses templates, so each item (title, location, date, description, url, etc) can be configured for each block. Very flexible and powerful!
- Customizable "footer" to include brief information about the calendar ("provided by so-and-so", "updated weekly", a link to the full calendar, ical feed link, etc)
- Customizable "no upcoming events" text to display when no events are coming up.
- Repeating and all-day events are handled
- "Today Only" option to show only events occurring on this calendar day.
Installation
- untar into modules directory (sites/all/modules)
- Download SimplePie (http://simplepie.org/)
- Copy simplepie.inc into the modules/gcal_events directory
- Create a cache directory that is writeable by the webserver (defaults to modules/gcal_events/cache)
Configuration
- Enable the module in Drupal
- Create an input filter to use for gcal_events (I recommend calling it gcal_events). You will most likely want this input filter to be accessible to anonymous users.
- Make sure to select this new input filter in the gcal events module configuration.
- In the module configuration, set the cache directory and number of blocks to display
- In the block configuration screen, configure block 0. Get the Calendar ID from google calendar.
- Still in the block configuration screen, set the block to an active region and save
You should now see a few upcoming events in the block you configured. You can tweak the title of the block and how the events are displayed in the configuration screens.
How to get Google Calendar ID and Private ID
(Note: As of gcal_events.module version 1.5, you can just copy and paste the XML address and the Calendar ID and Private ID will be parse out automatically) If you are testing out the module and need a calendar to try, I recommend a Google Calendar ID of usa__en@holiday.calendar.google.com. That is a public calendar of US Holidays. It is guaranteed to always have a few upcoming events and should work in all cases.
- Log into your Google Calendar.
- Click on the "Settings" tab.
- Select "Calendars"
- Click on the calendar you want to use.
- In the section labeled "Calendar Address", you should see "Calendar ID". Copy and paste that ID. into the GCal Events configuration.
If you just fill in the Calendar ID, GCal Events will default to using your public calendar. Events marked as private will not show up. If you want to display your private
calendar (not advised):
- Under the section marked "Private Address", click on XML
- You will see a URL that looks something like this:
- For Private ID, you are looking for the section between "private-" and "/basic"
http://www.google.com/calendar/feeds/somename%40gmail.com/private-0562849527c0abe35379accccb4ecfd4/basic
Template Customization
GCal Events was written to be a very flexible and customizable module. Rather than having people download the module and modify the code to meet their unique needs, I tried to write the module in a way that it can be configured to meet the majority of those needs.
Each Google Calendar XML feed contains events with the following fields:
- Title (#TITLE#)
- Location (#LOC#)
- Date (#DATE#)
- Time (#TIME#)
- URL (#URL#)
- Description (#DESC#)
In addition, GCal Events provides these modified fields for your use:
- URL-Encoded Location (#LOCURL#)
An event block uses templates to display these fields in the format you specify. The Event Template is the template that combines all the fields together. You can add html tags or linebreaks as needed between elements.
In addition to the Event Template, each field has a template of its own which specifies what should be done to that field before including it in the Event Template
Typically, you will want to keep the Events Template free of any customization that applies to a field individually, like a bold tag or linebreak tag. This is done so that if a field is missing from the XML feed, the extra linebreak will not be shown (for example, an all-day event will not have a time, so you do not want an extra blank line showing up for that).
Here are some example customizations:
- To get the title to be a link to the event in google calendar:
- To get the location to be a google map:
Title Template: <b><a href="#URL#">#TITLE#</A></b><br>
Location Template: <a href="http://maps.google.com/?q=#LOCURL#">#LOC#</A>
Time/Date Customization
Time and Date formats are very customizable. The default format for time/date display can be configured in the GCal Events administration page. Each block can also be configured to override that if you need a different display in a different block.
Timezone Configuration
On most systems, timezone configuration will not be needed. The "local time" according to the machine hosting your page will be what is used. If the machine is set up using UTC or a different timezone, you may need to select an alternate time zone to display the events correctly.
Feature Requests
- Configurable look-ahead time for events: Set a maximum time to look for events (next 30 days, next 5 days, etc). Current behavior is to look for ALL future events
- Current week/month/year only: Only display events from the current week, month, or year, rather than the next X events which might span a week/month/year border.
- php code: Allow a block of custom php to be executed for the block or for each event. This is a potentially risky feature, and unless a really good reason comes along, I see no reason to add it.
If you want/need one of these features or think of another feature you could use, please let me know! It's possible that it is already possible and just needs to be configured. If not, there's a possibility that if you could benefit from a new feature, somebody else could as well, and that would make a worthwhile addition.
More Information
Authors
- Originally written by Jeff Simpson
- Adapted from code written by James Cridland
Please post issues/suggestions/etc on the GCal Events Project Page. Comments posted here might go months before anybody sees them.
Comments
How often feeds are refreshed? Can I create Block 2 and how?
Great module, works OK. Does anyone knows how often feeds are refreshed and if I can/should adjust settings? Another tricky question: if I have 2 gcals and need to duplicate block with different feed what to do?
Confusing documentation
I don't know how to use this. I think the documentation needs to be explained better. How do I Create a cache directory that is writeable by the webserver (defaults to modules/gcal_events/cache)?
How do I Create an input filter to use for gcal_events (I recommend calling it gcal_events). You will most likely want this input filter to be accessible to anonymous users?
I'm lost and this documentation is very confusing. Please help
creating cache directory
After uploading the module to your webserver simply create a new folder in '/modules/gcal_events' named 'cache'.
Caution: Make sure to set directory permissions for the cache directory and refuse public read access. Otherwise it might be possible for everybody to list your cache entries and get your public and private calender id.