Topics:
Pulling Events from events.stanford.edu (or any other iCal feed) into Your Drupal Site
Prerequisites
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
- Advanced Help (advanced_help)
- CCK (cck)
- Calendar (calendar)
- Date (date)
- FeedAPI (feedapi)
- FeedAPI Mapper (feedapi_mapper)
- iCal Feed Parser (parser_ical)
- Views (views)
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
- 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
- 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
Source Target title Map to Title (node) description 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
- Choose a source, choose a target, and click Add
- 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 Section Option Setting Additional Information Filters Node: Published Yes Provided by default Filters Node: Type Event Arguments Date: Date (node) Action to take if argument is not present: Provide default argument of type current date
Granularity: Month
Date field(s): Content: Event Date/Time (field_date) - From dateRemove the default argument of Node: Updated date Fields Node: Title Provided by default Fields 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"
- Celebrate!