Last updated November 9, 2014. Created on November 12, 2012.
Edited by devarchivist, acabouet, serjas, jaisenan. Log in to edit this page.

It is fairly simple to display an event calendar for all event content on a site, but sometimes we need to display an date-specific calendar, e.g. for an event listing view. To do this, follow the instructions below.

Modules needed:

1. Create a new content type for events (e.g. 'events') and add starting and ending date fields. You can create now create your desired event content.

2. Add a new calendar view from the existing template in the calendar module(admin/structure/views add-template). From the list, you should select "A calendar view of the 'field_yourfieldname' field in the 'node' base table."(Display type of the view: Month)

3. In the edit mode of your calendar view, under filter criteria, select the event content type that you created above. Also add a contextual filter - 'Content: Nid'. Save the view.

4. Create a new view for your event listing. This view should have a page display. Under filter criteria, select the event content type that you created above. Add 'Content: Nid' as a new field and tick the option 'Exclude from display' in the configuration page. Add another field, 'Global: PHP', for grabbing the current date and passing it as argument to the calendar view. you should write 'print date("Y-m")' in the Output Code field and tick the option 'Exclude from display' in the configuration page.

5. Embed the calendar view in your event listing by adding a new field: 'Global: View'. (See the attached image for the configuration of this field.) Here you should specify the name of your calendar view in the View setting section and also specify the views display type. Then, you should add '[%php]/[%nid]' as a contextual filter for the calendar view. Save the view. Your customized event listing is now ready!

AttachmentSize
embedview.png37.44 KB

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

Comments

jincy_k’s picture

I have tried these steps and created an events listing page with the calender embedded in it easily. In drupal 7 when the calendar style is added to my view,got a missing plugin error..Somehow this post helped me and saved my time..In drupal 6 when the calendar module is installed,a default view called 'calender' will be created. We can override it for our purpose. Moreover we can add calendar navigation style there,which has been updated as a new option(admin/structure/views add-template => 'Add view from template') in drupal 7.Here,default view will not be created unless a view is created from the existing template as said before. This is a key update to be noted.