Calendar of Events Recipe for Drupal 6 that really works

Events happening in the community are now at Drupal community events on www.drupal.org.
gripmedia's picture

A workable "Calendar of Events" for Drupal can be a baffling ordeal to try and get working and usable. Even trying to get a recipe to work can involve hours of wading through patches and comments to get something usable. In an earnest effort to try and reduce the madness, here is a recipe that works very well for our latest project for a client, and includes fixes we developed ourselves.

This recipe is based on FHSM's excellent contribution here. And the argument error fix is based on BOFH_UK's excellent fix here. Thank you both for your excellent contributions.

No warranties expressed or implied, we just know we got it to work well in short order here. We hope this helps.

Here we go!


For Acquia Drupal 6.20

We used:

CCK - Ver. 6.x-2.8
Views - Ver. 6.x-2.7
Calendar Ver. 6.x-2.4
Date Ver. 6.x-2.7

Download and install the above modules to /sites/all/modules (or your module location to your install) and enable them at Administer › Site building > Modules if you have not done so.


Step 1: make a custom ‘event’ content type using CCK

Go to Administer › Content management › Content types > add content type

Name = “Group Event” (*or whatever title you want).
Type = “event”
Description = “Create a new event to appear on the sites calendar of upcoming events”

The following settings are largely a matter of site needs and preference:

Under “Submission form settings”
Title = “Event”
Body = “Details”
Under “Work flow settings”
Decide to best fit your site. It is worth considering unchecking “Promoted to front page” if this item is checked and does not fit the needs of your site.
Under “Comment settings”
Make decisions which are appropriate for your site.
Save your new event content type.
From the content type screen (Administer › Content management) select manage fields next to your new content type.
Add a new field
Label = “Event Date and Time”
Field name = “event_datetime”
Type = “Datetime”
Widget type = “text field with custom input format”

There is some debate over the correct type to select here. The widget type dictates the input UI and is really a matter of preference. It’s easy to change after the fact so try them all and see what you like best.

Save your newly created event date/time field.

The field options on the following page are reasonably self explanatory and a matter of taste.

Pay attention to the “To Date” option as it will allow you to set the end of your event (more important if you want an iCal feed ultimately).

For most people

Granularity = year, month, day, hour, minute (not second) selected
To Date = optional will be correct

You can of course add any number of additional fields to your event content type at this point using CCK.


Step 2: Create your first event

Create content > Group Event
Fill out the form for your event and save it.


Step 3: Configure your calendar view

Go to: Administer > Site building > Views

This is where it can get tricky.

Enable the Default Node view: calendar (Calendar)
Clone the default view

View name = “calendar”
View description = “Calendar of group events”

Next should take you to the views edit screen

Down the right side you'll see all the different types of calendar (page, block etc) just work with the default view to start (it should be where you are by default).

In the Arguments panel:

Click Date: Date (node.changed)
Near the bottom of the page under Date field(s):
uncheck = Node: Update date
check Content: Event Date and Time (field_event_datetime value)

Click Update

This sets the start time of your event instead of the node update time as the argument for the view.
On the Filters panel click the “+” button to add a new filter

Check = Node: Type

Click Add

On the following screen

Leave operator = “Is one of” and check = Events to limit your calendar to only the event content type.

Click Update

On the Sort criteria click the “+” to add a new criteria

Check = Content: Event Date and Time (field_event_datetime value)

Click Add


Save it all by clicking Save


Step 4: Fix the "The date argument date fields must be added to this query. You can exclude them if you do not want them displayed in the calendar." Error

  1. On the default edit view of the calendar page you should see the 'Fields' section with two entries in it (Node: Title and Node: Update or something like that).
  2. Remove both of those entries by clicking each one in turn and selecting Remove from the bottom of the form.
  3. Now you'll need to add two new fields. Firstly add 'Node: Title' back in and select 'Link this field to its node'.
  4. Next add 'Content: Event Date and Time (field_event_datetime) - From Date' and, again, link the field to its node. That SHOULD make the error messages go away.

Step 5: Make Sure it Works!

Use the View "Calendar page link to confirm your new calendar is up and working.

That will at least get you to a working calendar of coming events for your site. Obviously you’ve got a ton of configuration options to play with form here.

This is a very powerful package. While it's not hard to setup it's got a lot of steps and many opportunities to go wrong. The key here is to set the argument / sort / filter bit of views configuration. This combination of modules seems to want to create a calendar widget for digging into the archives by default but it is easy enough to have it do otherwise.

Hope this is helpful for someone down the road.


The following are optional, but highly recommended.

Optional 1: Fix iCal feed export to actually work

The above steps view defaults causes the iCal export to not work properly. It will import into Apple’s iCal or MS Outlook but will be blank.
Note: You must have the Calendar iCal module installed and enabled
Here is how to fix it:

  1. Edit the “Calendar” View you created.
  2. Click on iCal Feed
  3. Remove any Arguments that may exist, should end up saying “none”
  4. Add a filter: Date: Date (node) Content: Event date (field_event_datetime) - From date >= now +1 day
    • Click “+” to add a filter
    • Check Date --> Date: Date (node)
    • Click Add, this will take you to next screen
    • Date form type --> Select
    • Granularity --> Day
    • Date Year Range -3:+3
    • Check Date Field: Event date (field_event_datetime) - From date
    • Method --> Check “OR”
    • Click Update, this will take you to next screen
    • Operator --> Is Greater than or equal to
    • Don’t set an absolute date
    • Set the Relative Date Default to be: now +1, leave the "To Date Default" blank.
    • Click Update

This SHOULD fix the iCal feed export to work properly. Note: if on a view and the event has already passed, it will NOT add a past event.


Optional 2: Add a JQuery time-picker

The default time entry is tedious, bothers every client I have and is not very useful. I recommend adding the excellent Date Tweaks Module and this will add a time-picker to your event fields. Don’t do like I did and not bother to read the instructions. Read their install instructions carefully or it will not work.

Comments

Thanks

SMN's picture

Thanks for the post. Its really useful, step by step in detail. Not only my calendar is working fine, but also i understood the process thoroughly.

iCal Feed

Donaldini's picture

I wanted to add the functionality of exporting an iCal Feed, but I can't seem to do this with my Drupal 6 installation.

"Optional 1: Fix iCal feed export to actually work
...
1. Edit the “Calendar” View you created.
2. Click on iCal Feed"" <-- This is missing??

Use calendar as 'exposed filter'

dutchyoda's picture

Hi,

Is it possible to make de calendar only highlight the days when an event is planned.
And if you click on that day the events are shown underneath.
Just like it would with a exposed filter?
I need this in D6 and I've got a hard time readjusting from 7.

hi

venketcse52's picture

how to delete,edit event in event calendar....

Event Management Systems

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: