Pulling Stanford Events into Drupal
Pulling Events from events.stanford.edu (or any other iCal feed) into Your Drupal Site
This tutorial assumes that you know how to:
- Download and install Drupal modules
- Configure permissions
- Create custom content types using the CCK module
- Enable and configure Views (the Views themselves, not just the module)
Download and Install Modules
The Advanced Help module provides instructions at help/date_api/ical-import
Create Two CCK Content Types
- Create a CCK content type ("Event")
- In addition to the standard fields, add a Date field and choose "Text field with Date Pop-up and Repeat options" as the input form element
- Create another CCK content type (“iCal Feed”)
- This will be an "umbrella" content type for pulling in iCal feeds from any source
- On the content type creation screen, twirl open the FeedAPI fieldset
- Check "Is a field content type"
- Choose URL under "Supply feed as:"
- Check "Refresh feed on creation"
- Update existing feed items
- Check this if you want the information from the feed to override any local in-Drupal modifications to Events
- Uncheck this if you want to pull Events in via an iCal feed, then modify them within Drupal
- Minimum refresh period: The default (3 hours) is usually fine for this. Stanford Events only updates their feed every 8 hours (as of January, 2010), so if you are only pulling in from events.stanford.edu, you can set this to 8 hours.
- Delete news items older than: You can modify this setting to have Drupal clean up old Events that it has pulled in from a feed
- Parser settings
- Choose the iCal parser
- Processor settings->FeedAPI Nodes
- Check Enable. This will create new nodes (of the CCK type "Event") in your Drupal site based on the iCal feed that you provide below.
- Choose Event under Node type of feed items
- Input format for feed items should be set to Filtered HTML or Default format (if Filtered HTML is your default format). Choosing another format is not advisable, as it opens your site up to XSS attacks.
- Created date of item nodes: typically would be set to Retrieve from feed
- Duplicates: typically can be set to only within feed
- Processor settings->FeedAPI Inherit
- We will not be using this feature in this example
- Note: Be sure to give yourself proper permissions to access all of the new fields and content types you have created.
Create an iCal Feed Node
- Now, create a new node of iCal Feed content type (at node/add/ical-feed)
- We'll be pulling events from the Stanford Open Source Lab, so we'll use "Open Source Lab Events" as our node title
- Feed fieldset
- Feed URL: Stanford Events publishes iCal feeds for organizations and categories. Right-click the iCal icon and choose copy link location. Paste that into the Feed URL field (e.g., http://events-prod.stanford.edu/byOrganization/993/eventlist.ics)
- All other settings should inherited the defaults you set up when you created the iCal Feed content type. You can change these on a feed-by-feed basis if you wish.
- Save the node
- Now you need to map your feed items. Click the Map tab at the top of the node (next to View).
- Choose a source, choose a target, and click Add
|title||Map to Title (node)
||Map to Body (node)
|options->VEVENT->DATE->DTSTART->datetime||Map to field_date (date): Start Date (date and time)
|options->VEVENT->DATE->DTEND->datetime||Map to field_Date (date): End Date (date and time)
- If you want to map additional fields, twirl open the Feed item example fieldset to see what the source fields look like
- Cross your fingers, then click Remove items (next to Map), and then click Refresh
- You can view the newly-created nodes at admin/content/node; verify that they have the correct title, body, and date/time
Note: Periodically, you may need to remove items and refresh.
Create the Calendar View
- Go to admin/build/views
- Scroll down past all of your active Views to the disabled Views. Find the calendar View (provided by the calendar module) and click Enable.
- This tutorial assumes that you know your way around the Views UI screen. As such, here are the relevant settings:
Calendar Views Settings
||Provided by default
||Date: Date (node)
||Action to take if argument is not present: Provide default argument of type current date
Date field(s): Content: Event Date/Time (field_date) - From date
|Remove the default argument of Node: Updated date
||Provided by default
||Content: Event - From date
||Remove the default Field of Node: Updated date
- Save the view
- Go to /calendar (the default path of the calendar View) to view your calendar, um, "View"