Recently ThinkShout needed to include an “add to calendar” widget on a client’s event pages, but, to my surprise, no Drupal module existed that fit what I needed. Since this seemed like a relatively common feature, I set out to write my own module to release to the Drupal community.
Thus Add to Cal was born, a module that adds a field formatter for dates in the form of a button that allows exporting an event to a small variety of popular formats, namely Google, Yahoo, Outlook, and iCal. While PHP is very much a strong point for me, this was the first real module I had created for Drupal, and it proved to be a great adventure and an excellent learning experience.

Abstracting the Module for All
One of the challenges for me while writing this module was abstraction. While it’s relatively easy to build and deploy a module like Add to Cal for one or two client projects, it can be a bit formidable for a first-time module developer to abstract the functionality for use on any site. Abstraction means removing all hard-coded values and providing a mechanism for easy integration.
For Add to Cal, the best abstraction method was to make it available as a field formatter. This provides an easy way for the widget to be attached to a date field belonging to any type of entity and, if desired, allows the widget to be individually present on multiple entities.
How it Works
The goal was to make Add to Cal fairly simple to install and set up for any site. Once the module is enabled, it can be attached to a display through the “Manage Display” tab. Next to a date field, choose “Add to Cal” for the format. That’s pretty much it!
The field formatter settings provide a way to map a location and description from other fields on the same bundle, and specify whether the widget is shown for past events (which is turned off by default). The standard date field options are also present, so you can still set the date format and display options for the field.
Once enabled, the Add to Cal widget will automatically appear next to the date field that uses it as a format. It comes with some basic styling that can be easily modified through CSS.

What’s Next?
The first beta version has been released on drupal.org. But the adventure doesn’t stop here – I plan on implementing several changes in the near future to make the module more robust.

Comments
Heh, I planned to create this
Heh, I planned to create this module some months ago, but another project came in, and I couldn't get back to it... the sandbox is still on though! http://drupal.org/sandbox/Ralt/1163848
Thanks for creating this module! I'll see if I can drop by the issue queue :-)
Awesome! I look forward to
Awesome! I look forward to seeing some good stuff in the issue queue.
I'd *love* to use this since
I'd *love* to use this since I'm under pressure to put iCal features onto our website. However, we're stuck at Drupal 6. Ah!
Very nice!
Exactly what I was looking for. I implemented it on my kids' elementary school's PTO website. Check it out at http://www.wardpto.org/calendar/day/2012-09-13/curriculum-night.
Thanks for your contribution!!
Cool Module
I just set up the addtocal module - it seems to do exactly what I need. I can use your module for specific events - the "add to google" worked great for me. along with date_ical for the ical feed for views. just what the doctor ordered.
Great. just I have a probleme
Great. just I have a probleme It not work for Outlook, When I select Outlook it does not downlod de "ics file
It works now thank so much
It works now
thank so much
Outlook and iCal links dont open the file.
Hi there, would you be able to share how you got it to work?
I am having the same issue
It dosn´t work with iCal?
Hello, I installed the module. It does not work when I select iCal. Is there a trick?
[closed] It dosn´t work with iCal?
I forgot Entity API ;)
Drupal 6
This module looks great and is exactly what I'm looking for, but I'm working on Drupal 6, not 7. Is there a complimentary version of this I could use or do you know of any other modules that allow me to have an 'add to calendar' feature?
Unfortunately, no...
We've not seen anything in D6 that would do the trick, and since almost all of our clients use D7, it's not likely that we'd backport the module.
Bummer...
But thanks for letting me know.
Can't open ics
Great module by the way, however, I'm having trouble opening ics in ical. If I run it through a validatior: Sorry, your calendar could not be parsed.
I'm getting the BOM before BEGIN:VCALENDAR
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
IF I just open the ics file in a text editor and save it, it will open in ical fine.
Any help is appreciated.