Thursday, November 1, 2012

Creating an iCal Feed for a Single Node in Drupal 7

Here are updated instructions on how you can create an iCal Feed for a single node in Drupal 7 with the new Date iCal module. The functionality to create iCal Feeds has been separated from the Drupal Calendar module to the Date iCal module.
  1. Create a Block View for the content type(s) that you want to create the iCal Feed.  Keep in mind that this block needs to be put on your node page, so make sure that your block contains items that you would like to display on the node page.

    Here is a sample of the end result:

  2. Views will force you to display at least one field.  If you want an empty block with just the iCal feed, you can use the Global: Custom Text as your Field.  Hide the label and leave the text box empty.

  3. Add a Contextual Filter of Content: Nid to your Block view.

  4. Set up the Contextual Filter so that it gets the default value of Content ID from URL.  This way, your iCal Feed will only show information for the node that is loaded on the page.

  5. Now add a Feed to your View and configure it to display iCal Feeds.

  6. Don't forget to add the fields that you want included in your iCal feed...

  7. ... and add a Path to the Feed view.  Make sure it ends in .ics.
    (Edited: Dec 1, 2012 - thanks to @derekw from the for correcting this.) Add a wildcard placeholder for Views to use/insert the nid into.  For example, your path might be events/%/ical.ics.
    You will also need to attach the feed view to the Block that you created earlier.

  8. Once you save the view, you can place your empty block with the attached iCal feed on every node page.  The results should be like that illustrated in step 1.