You are on page 1of 5

Get Started Community Documentation Support Download & Extend Marketplace About

Step by step guide to create an event listing with calendar block in Drupal 7
Community Documentation
Community Docs Home Installation Guide Administration Guide
Page status
Needs technical review
Log in to edit this page
About this page
Drupal version
Drupal 7.x
Audience
Programmers, Site administrators
Level
Intermediate
Keywords
Calendar , D7 , Date , Drupal 7
Site Building Guide
Best practices
Building the site functionality
Access Control
Actions and Workflows
CRM Systems
Commerce and Advertising
Connecting to other Sites,
Systems, and Data
Content Authoring Modules
Content Display Modules
Content Modules
Content Recommendation
Dates and Events
Booking Timeslots
Booking shared resources
Date/Calendar
TROUBLESHOOTING:
Debugging date and
calendar problems
Drupal 7
Date/Calendar
Date Field Types
Date Locale &
Time Zone
settings
Cookbook:
Drupal Homepage Log in / Register
Last updated September 5, 2012. Created by juampy on August 16, 2011.
Edited by gambry, Sk8erPeter, KarenS, jmary. Log in to edit this page.
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
latest development build of calendar, date, ctools and views modules
context and context_ui.
features (needed by the feature module mentioned above).
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 "Save 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):
In the search field type "Date: Date (node)", once found click on "Add and configure
contextual filters".
1.
At the "When the filter value is NOT in the URL", select "Provide default value". 2.
At Type in the drop-down list, select Current Date. 3.
At Date field(s), select "field_event_date". 4.
At Method, select "AND". 5.
Save. 6.
Create a calendar block for events
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.
1.
Select the Block display and add a filter by content type so it only lists content of type
"Event".
2.
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
3.
Search drupal.org
Refine your search
Step by step guide to create an event listing with calendar block in Drupal 7... http://drupal.org/node/1250714
1 of 5 12/21/2012 8:56 PM
Prepare an
Event-Calendar
for Drupal 7
Cookbook: Use a
special
Date-Format
D7 Organic
Group Calendars
Date API
DateObject Class
and Functions
Date Form
Elements
Step by step
guide to create
an event listing
with calendar
block in Drupal 7
Drupal 6
Date/Calendar
Archive: Drupal 4.7 &
5 Date/Calendar
Event modules
GCal Events
Installation instructions for
Eventbookings
MERCI (Manage
Equipment Reservations,
Checkout and Inventory)
Project: a rich set of tools
for (software) project
management
Signing up for events with
CCK Signup (Drupal 7)
Signing up for events with
CCK Signup
Signup integration for
Ubercart (UC_Signup)
Storm (project
management application)
Subscriptions (Subs)
Timeline Module
Documentation tools
Dynamic menu elements with
tokens
E-Mail and Messaging
Features packages
Forms
Games and Amusements
Geographical data and maps
Input formats
Media and Files (D6, D7)
Search
Search Engine Optimization
Social Networking and
Collaboration
User-Generated Content
WYSIWYG configuration /
image handling / editor role
management
Contributed modules
Core modules
Distributions
HowTos
SWFAddress: Browser History and
Date Form Elements up Drupal 6 Date/Calendar
Login or register to post comments
Login or register to post comments
when using the appropriate template (see the screenshot in step 1).
Save. 4.
Add the calendar block to the events view
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
1.
Save the context 2.
Verify that opening /events lists the created events with a calendar block at the
sidebar.
3.
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
<?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'];
}
?>
Login or register to post comments
Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.
Comments
Cal endar probl ems
Posted by gtrennert on September 21, 2011 at 10:34am
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 ?
Requi rements
Posted by juampy on September 21, 2011 at 11:16am
Does your test meet the requirements for the required modules? (See "Download and
enable the required modules" at the top of the page).
Issue wi th future events by day in events view
Posted by teekay78 on November 18, 2011 at 1:50pm
I have a strange issue. I cannot acces future events via the link in the calendar.
Step by step guide to create an event listing with calendar block in Drupal 7... http://drupal.org/node/1250714
2 of 5 12/21/2012 8:56 PM
Deep-Linking for Flash/Flex
Site recipes
Drupals online documentation is
2000-2012 by the individual contributors and
can be used in accordance with the Creative
Commons License, Attribution-ShareAlike
2.0. PHP code is distributed under the GNU
General Public License. Comments on
documentation pages are used to improve
content and then deleted.
Login or register to post comments
Login or register to post comments
Login or register to post comments
Login or register to post comments
Login or register to post comments
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?
Number l i nks goi ng to page not found
Posted by kcharity on January 11, 2012 at 12:25am
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.
same i ssue
Posted by antoineyow on January 11, 2012 at 1:00am
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.
Future-proof?
Posted by pushka on March 13, 2012 at 5:25pm
I wonder if the same can be achieved using the new create-from-template process of
making calendars?
has-event cl ass
Posted by davifr359 on June 22, 2012 at 12:31pm
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.
Event content type uni nstal l abl e/undel etabl e?
Posted by AbelT on June 26, 2012 at 9:06am
Hello,
Step by step guide to create an event listing with calendar block in Drupal 7... http://drupal.org/node/1250714
3 of 5 12/21/2012 8:56 PM
Login or register to post comments
Login or register to post comments
Login or register to post comments
Login or register to post comments
Login or register to post comments
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.
Abel T
Not del eteabl e
Posted by kenyan on July 31, 2012 at 10:08pm
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.
It' s how Features modul e work
Posted by juampy on August 1, 2012 at 8:48am
To delete a content type from a feature, you need to recreate the feature without
it. Then you can delete it.
Recreate the feature???
Posted by AbelT on August 2, 2012 at 9:52am
Hello,
Thanks for your help but.... what does it mean "recreate the feature without
it"????
Can you explain a bit deeply, please?
Thank you!
Abel T
Let' s move to the i ssue queues
Posted by juampy on August 3, 2012 at 9:33am
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.
need clarifi cation
Posted by tiki16 on August 9, 2012 at 9:30pm
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
Step by step guide to create an event listing with calendar block in Drupal 7... http://drupal.org/node/1250714
4 of 5 12/21/2012 8:56 PM
Drupal News
Planet Drupal
Association News
Social Media Directory
Security Announcements
Jobs
Community
Getting Involved
Services, Training & Hosting
Groups & Meetups
DrupalCon
Get Started
Documentation Home
Installation Guide
Site Building Guide
Support
api.drupal.org
Download & Extend
Drupal Core
Modules
Themes
Distributions
About
Druplicon
The Drupal Association
Advertise
About Drupal.org
Web accessibility
Drupal is a registered trademark of Dries Buytaert.
Login or register to post comments
Login or register to post comments
Login or register to post comments
Also, I want this to reside in the main content of a page, not a sidebar. Does the code you
provided still apply?
thanks
The Context module enables
Posted by pushka on August 22, 2012 at 7:02am
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).
Hi, Al l worki ng for me i n
Posted by miraje on August 26, 2012 at 3:57pm
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.
Step by step guide to create an event listing with calendar block in Drupal 7... http://drupal.org/node/1250714
5 of 5 12/21/2012 8:56 PM

You might also like