Last updated November 23, 2013. Created on November 22, 2013.
Edited by areke, texas-bronius. Log in to edit this page.

The two recommended methods of creating calendars in D7 are from a Views template or cloning an existing one. If you had any question, yes, you absolutely can create your own calendar from scratch. This guide describes how to create a Drupal 7 Calendar of nodereferenced Dates as a Field on an Entity using EVA: Entity Views Attachment.

With that, have some sample data ready, and by the end of this you'll have a nice calendar.

Scenario and Goal

In this example, the node architecture is a Parent > Child configuration where Schedule nodes contain a date field and point to Event nodes via node reference. The goal is to have the Event node show a calendar of all of its occurrences for the month in the node view.

Schedule A |
Schedule B |---> Event A

Schedule C ---> Event B

and not

Event A
   |-->Schedule A
   |--> Schedule B

(even though that's how it ought to appear to the user)

Method

Views: Create EVA

In Views, create a new View of type Content, select normal set up you would to display these fields including at least 1 Field like Title. Choose Unformatted or anything not Calendar just yet so that you can be sure you've got the right configuration selecting and displaying the right data before moving on.
Create a display: Add "EVA Field" and configure for entity and bundle to match your Event entity (for me it was node > Event).
Add contextual filter of type Content: Event (this is the Schedule entity's nodereference field) and set its "When filter not available, Provide Default: Content ID from URL"
You ought to be able to test this in Preview at the bottom by typing a test Event node's nid and hitting Update Preview.

  • Looks good? Let's move on.
  • Not so good? Check out EVA documentation. This is not the place for that.

Views: Add display or Set EVA as Calendar

Either add a new EVA display (clone the previous one) or continue along with the same one just created.
Calendar is rockin', but it needs a push in the right direction. Set your Display's Format "Format" to Calendar, set its settings to Month and leave the rest as default.
Set your Format's "Show" to Calendar Entities, keep all defaults.
Add another Contextual Filter: Date, find your Schedule entity's date field.
Set "When filter is not available" to Provide Default: Current Date. Set Granularity to Month. Start/End range.
Add a pager. Note: If you had a pager already or need one to be different, be sure to select "For this display only" if applicable. Choose "Page by Date", keep defaults.
Again, enter the nid of your sample Event node and hit Update Preview in at the bottom of Views UI. If it worked, you will see a Month showing all appropriate dates populated with the Fields set up in this View earlier.

  • Looks good? Let's move on.
  • Not so good? Please add a comment here for help or edit this handbook to fix/clarify.

Node: Manage Field Display

In Drupal admin, visit Structure > Content Types > Event > Manage Display and pick the appropriate display.
For me the right display is "Full content," so give that a click. Here you should see a new field provided by EVA called "EVA: (name of your EVA View's Display). Move the EVA: field up or down and set its configuration.
Save changes, and view your sample Event node.

  • Looks good? Congratulations.
  • Not so good? Please add a comment here for help or edit this handbook to fix/clarify.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.