The contents of this guide should be tested along the Events calendar feature module as a working example. It is recommended to install and test this feature module first and dive into the step by step guide if needed.
If you get "The calendar row plugin is required when using the calendar style, but it is missing." notices, you should uninstall the feature and follow the steps below.

Below are the list of steps to create an events listing with a calendar block which filters them.

Download and enable the required modules

Create an Events content type

Go to Structure > Content types > Add content type (admin/structure/types/add) and create one with the following settings:

  • Name: Event
  • Fields: Add a field of type Date, field name event_date and label Date(s). In the field configuration screen check the "Required field" and "Collect an end date" checkboxes.
  • Create three or four events at the "Add content" (node/add/event).

Create a view to list events

Go to Structure > Views > Add new view (admin/structure/views/add) and create a view showing nodes of type "Event". Click on "Continue and edit".

Set the path of this page view to /events.

Add the following Contextual Filter (find the link at the Contextual Filters block when editing the view - often hidden under Advanced on the right - you need to click it to show more):

  1. In the search field type "Date: Date (node)" - select (Apply) then on the next menu
  2. "Add and configure contextual filters".
  3. go to "When the filter value is NOT in the URL", select "Provide default value".
  4. At Type in the drop-down list, select Current Date.
  5. Now scroll down to Date field(s) and select "Content: Event Date - start date (field_event_date)" / "field_event_date"- this is the date you set when creating the Content Type Event. You may have chosen different names - so be aware, especially if you already have dates used in other Content Types.
  6. Scroll down further to Method, select "AND".
  7. Save.

Create a calendar block for events

  1. Clone the view "Calendar" into "Events calendar". ›› UPDATE (2012-08-23, related to Calendar 7.x-3.4): you should rather use "Add view from template" on admin/structure/views depending on the appropriate field. Sample screenshots: "Add view from template"; Views + Calendar templates.
  2. Select the Block display and add a filter by content type so it only lists content of type "Event".
  3. Edit the Contextual Filter so it looks exactly the same as the one we configured at the Events view. ›› UPDATE (2012-08-23, related to Calendar 7.x-3.4): this is already set when using the appropriate template (see the screenshot in step 1).
  4. Save.

Add the calendar block to the events view

  1. Using Context module, create a context (admin/structure/context/add) so if the condition is the Events view, display the "Events Calendar" block in the sidebar
  2. Save the context
  3. Verify that opening /events lists the created events with a calendar block at the sidebar.

Link the calendar block links with the events view

Add the following code to your default theme. Remember to change "yourtheme" by the name of the default theme. This code shoud reside at sites/all/themes/yourtheme/template.php

/**
 * Alters link url in calendar events block in order to filter events at /events
 *
 * @see template_preprocess_calendar_datebox()
 */
function yourtheme_preprocess_calendar_datebox(&$vars) {
  $date = $vars['date'];
  $view = $vars['view'];
  $day_path = calendar_granularity_path($view, 'day');
  $vars['url'] = 'events/' . $date;
  $vars['link'] = !empty($day_path) ? l($vars['day'], $vars['url']) : $vars['day'];
}

Comments

gtrennert’s picture

Hello,

I can see that there are technical reviews needed, but I tried out this step by step :
My problem is : when clicking on an date with event in the calendar (i.e. 20 oct), i get :
1) a second calendar below the first one with a totally other date with event (i.e. 30 oct)
2) This message : Debug :
'calendar_plugin_style: Missing calendar row plugin'
dans calendar_plugin_style->render() (ligne 205 dans ...\sites\all\modules\calendar\includes\calendar_plugin_style.inc).

Can you give me a hint how to get this thing working ?

juampynr’s picture

Does your test meet the requirements for the required modules? (See "Download and enable the required modules" at the top of the page).

teekay78’s picture

I have a strange issue. I cannot acces future events via the link in the calendar.

Lets say I have an event on 2011-12-24

events/2011-12-24 <- shows nothing
events/2011-12 <- shows all events in 2011-12, including -24
events/2011 <- shows correctly too

All events in the past work fine. The upcoming events block also works correctly.

Any ideas?

kcharity’s picture

I have tried to get this going but have ran into a little roadblock. I have 2 post types with events in both types created. When I go to the monthly calendar (www.mydrupalinstall.com/calendar/month) I am shown all the events for those two post types and the event titles work just fine, but when I click the numbers I get sent to a page not found (www.mydrupalinstall.com/events/2012-01-11). This also happens when I use the block calendar and click on a number.

When I disable the module the numbers take me to the day view of the calendar and show that days events.

I have tested (www.mydrupalinstall.com/events/) and get page not found. Am I missing something? Why are the numbers pointing to "/events/2012-01-11" and not the event? Am I supposed to create a new view that lists all events for a certain day?

I am still a bit green when it comes to Drupal so please be gentle.

antoineyow’s picture

i have a similar issue basically my view sum up the amount of events I have for the day and displays the follow message on my calendar (click to see all xxx events). Here is the problem the URL doesn't show up like the example my-drupal-install.com/calander/month/2012-05-01 instead it shows up like this my-drupal-install.com//2012-05-01.

I tried both ways but none shows the list of my events.

aguztinrs’s picture

Hi!

Did you fix this issue?
I've the same issue and I don't understand what's the reason?.

Jason Dean’s picture

I wonder if the same can be achieved using the new create-from-template process of making calendars?

davifr359’s picture

I need to hilight the days - in the calendar - with have at least one event for it. The calendar return the classes has-events an has-no-events, but it returns has-events for day that has no event registred.
I will have to code this part to return the correct class? Or in the new version this feature is coded?

Thanks.

AbelT’s picture

Hello,

As I have seen, this step by step guide shows all steps that the "Event Calendar feature" module makes.

I tested it in my site, but I saw it was not appropiate for me. I defused using it clearing the checkbox at the module list.The views that were created automatically when the module was enabled, dissapeared, OK.
I deleted the content created for testing module.
And when I go to delete the "Events" type content, I find that this type of content hasn't got the "Delete" option.

If I have deleted all related content, I should be able to delete this type of content, shouldn't I? What's the problem?

Thank you very much.

kenyan’s picture

Same here,
This wasn't 'working' for me either so I uninstalled the feature and all related content.
The Event content type though is now a real pain. There is no way to remove it.
I guess this means having to delve into the database but this should not have to be the case.

juampynr’s picture

To delete a content type from a feature, you need to recreate the feature without it. Then you can delete it.

AbelT’s picture

Hello,

Thanks for your help but.... what does it mean "recreate the feature without it"????

Can you explain a bit deeply, please?

Thank you!

juampynr’s picture

This page is informative. Feedback related with errors it is better handled at the module's issue queue (http://drupal.org/project/issues/events_calendar_feature?categories=All).

Please find a related issue there or create one to keep on this discussion.

tiki16’s picture

Hi Not sure what you mean here:
Using context module, create a context so if the condition is the Events view, display the "Events Calendar" block in the sidebar

Also, I want this to reside in the main content of a page, not a sidebar. Does the code you provided still apply?
thanks

Jason Dean’s picture

The Context module enables you to create rules and reactions. For example, if a page has path 'blog/*' then 'display the Blog Archive block in the right sidebar region'. So you can use Context to enable the calendar block on a specific Views page. Context module is very flexible.

To display the calendar block (or any block) in the main content of a page, you can place it in the Content region. Or if this doesn't fit with your layout/theme, consider using Panels module which provides much more flexibility for placement of page elements (though a fair bit more complexity too).

miraje’s picture

Hi,

All working for me in case when in Contextual Filters I select node's creation date or node's update date. But, if I select Date: Date (node), like explained in this tutorial - I get and empty calendar!!!
The interesting thing, that in $view object the needed nodes do exist, and running view's query directly against the database returns me my Event nodes. But the calendar is empty!!!

Changing type of the Date field (ISO, Unix timestamp) doesn't help.

Inserting to Contextual Filters also node's creation dates place nodes in the calendar by their creation date dates - it seems like the Calendar's object totally ignores my custom date fields.

What am I doing wrong?
Any help would be appreciated.

AntonLargiader’s picture

I'm running D7 and stuff just isn't matching up. At field name event_date I find that the field has to start with field_. For ..create a view showing nodes of type "Event" I never have node as a choice. For Click on "Save and edit" I get 'save and exit' or 'save and continue.' Etc. Is it me, or are these instructions obsolete?

klaats’s picture

This guide is getting me nowhere for Drupal 7, it's a shame because this was exactly what i needed !

flabel’s picture

Been wasting time on this module since it is not maintainted any more. Please update the status so other people are not wasting there time.

dude74’s picture

Hi,

This solution worked for me, but didn't sastisfy me totally : when I click on a day, event list (configured by view) shows correctly, but mini calendar block always reset to current day. Not really a magic navigation !

I finally find a very simple issue, without additional code, to use mini calendar block as valid navigation tool, modifying default date argument thanks to url this way :

STEP 1 - modify code above to insert to your template.php

/**
* Alters link url in calendar events block in order to filter events at /events
*
* @see template_preprocess_calendar_datebox()
*/
function yourtheme_preprocess_calendar_datebox(&$vars) {
  $date = $vars['date'];
  $date_month = substr($date,0,7); // variable I introduce to place it in the path
  $view = $vars['view'];
  $day_path = calendar_granularity_path($view, 'day');
  $vars['url'] = 'events/' . $date . '/' . $date_month;
  $vars['link'] = !empty($day_path) ? l($vars['day'], $vars['url']) : $vars['day'];
}

Links for day with content now shows, for example today : "events/2013-03-17/2013-03"

STEP 2 - change default contextual filter of your 2 views, calendar block & Event list

Calendar block : At the "When the filter value is NOT in the URL", select "Raw value from path => path component = 3".

Event list : do nothing (finding first argument "2013-03-17" alone scanning the path".

It works fine when you click on a day with event, mini calendar block month ties to the "active" event month currently shown. But the base url you define in your event list view ("/events") causes 404 error for me because there is no default argument in the path. Issue in step 3...

STEP 3
My issue was to provide default argument in the path when user access to event list view page. Using menu token module, I create a menu item with following link : "events/[current-date:custom:Y-m-d]/[current-date:custom:Y-m]".
For example, today, my menu link is "events/2013-03-17/2013-03" showing events of the day. When user click on a day, mini calendar block now follows...

Warning : I had to apply patch to menu-token and crumbs module, because I had error message while doing job fine...

Not native english (I think you already understood it :-o)), so apologize...

jibize’s picture

Dude74,

You should be able to achieve the same result by just editing the Calendar Event block contextual filter, and inserting the following in the "Provide default value" > "PHP code":

if (arg(1)) {
  return substr(arg(1),0,7);
}
else {
  return date("Y-m-d");
}

No need to alter the hook_preprocess_calendar_datebox() snippet from the original post or install additional modules. ;-)

Edit:
To get the Calendar Event block showing the full month when on the page /events, better use:

if (arg(1)) {
  return substr(arg(1),0,7);
}
else {
  return date("Y-m"); // No need to specify the day here.
}
arlingtonvoicellc’s picture

Thanks! This was the only issue holding me up. This solution solved the problem. Great tutorial all around.

season90’s picture

After several days, this tutorial worked out for me on D7. I followed everything from the first tutorial but then I went down into the comments and erased the default events calendar view and re-did it per the comments.

kvguser2’s picture

Followed all instructitons.

Getting "If you get "The calendar row plugin is required when using the calendar style, but it is missing."

Advice to "uninstall feature" are not serious - really elaborate installation, so I have to "uninstall" the whole thing now? Seriously?
And what "feature" actually - you mean all these modules needed?

kvguser2’s picture

* Instructions are *OLD* since modules were changed (enhanced).
CRITICAL in "Create a calendar block for events", step 2 is to *not* add a filter by content type - it is added automatically if you used "Add view from template"

* I found no use of "context" - works without it

bradallenfisher’s picture

Just curious, is there a way to have the mini cal filter a block with events rather than a page (path)?

borntosucceed’s picture

Thanks for the instructions, almost works. I am able to view the calendar and it works fine in the week or day view of the calendar. However when in Month view, I get following warning messages:

Warning: Illegal string offset 'data' in template_preprocess_calendar_month() (line 38 of /var/www/drupal/docroot/sites/all/modules/calendar/theme/theme.inc).
Warning: Illegal string offset 'data' in template_preprocess_calendar_month() (line 43 of /var/www/drupal/docroot/sites/all/modules/calendar/theme/theme.inc).

The calendar is still displayed correctly.

Any ideas why?

Thanks

Marilyn Moore’s picture

I also have a trouble solving the same problem that's when i click month view, the same warning pops out. The problem has haunted me almost 2 days and has driven me crazy. Have solved the problem? if you have, please help me to fix it! Thanks a lot!

borntosucceed’s picture

Sorry not fixed yet - currently in the too hard basket for me

drlakshan’s picture

Thank you very much. The exact point that helped me was "Contextual Filter" section. Thanks.

NGiacopuzzi’s picture

So I have the calendar working correctly for the most part on /events

Although it is not formatted like the regular calendar view, even when using the add view from template.

the main thing im having an issue with, i need to display the calendar in a panel. I added the view "Event" to the panel. And nothing at all renders. Is there something special i need to do here?

i can see the calendar on the usual /calendar-node-field-event-date url and i see it on /events (just not formatted properly)

but when adding the events view to my pane....NOTHING. Any ideas?

*EDIT*

I have managed to get it displayed in my panel...however, there is no navigation to next month etc. is there something i need to add for this?

computerology’s picture

Ok this is got me at wits end.

I got the latest version of Calendar and Date. Date/Calendar had an automatic option to create the view and the fields for me which was great. Went through the views with a fine toothed comb, all looks good. Preview looks good. Created an event/date in the month I am trying to display as I am testing (February).

Every single thing shows up as a blank page. If I refresh I can see the calendar for a nanosecond but it dissapears instantly. The rest of the page is a big blank space. The drupal load is pretty fresh, I used a template from templatemonster.com and I'm not a complete rookie, I did manage to get this working on D6 at one point but its anything but intuitive.

All I want to have Drupal do is:

1. Display a monthly calendar on a link, giving the user option to page forward and backward, switch to day view
2. Display an "add a date" link at top, I dont even care if it shows up for the anonymous role because they dont have permission to add a date
3. Be able to parse this into a block, preferrably mixed in with new articles in a list, but I'll take a mini calendar if I have to.

The problem is nothing shows at all. I dont want to sound grumpy but I had similar nightmares on D6. A simple event calendar is such a needed module and it's not rocket science. In eXOOPS/RUNCMS I would have the thing up in about 5 seconds. Surely someone with better PHP coding skills than me can save the world and make a calendar module that just works...

Please help.

rwilson0429’s picture

After modifying your template.php as per the step-by-step, you should flush all caches.

ReggieW

ling-drupal’s picture

Hi Does anyone can help me out with this question? with mini calendar block, when click on day link, it display lists of events of that day instead of day calendar view?

thanks so much for any suggestion!
Ling

svogt0511’s picture

I know this is a 4 year old post. Here is a newer video that describes this process pretty well (using a template that now come with the calendar module).

http://codekarate.com/daily-dose-of-drupal/drupal-7-calendar-module

arlingtonvoicellc’s picture

-REMOVED-

Mani253’s picture