I’m trying to use a combination of date, calendar, views, and cck to make a calendar of upcoming events and I’m not having much luck. The basic problem is that my calendar view is sorting based on the changed field in the node table, not on the date and time set for my events.

I'm going to make this detailed so thanks so much in advance for your help!

To get to this point I:

I used CCK to make a new content type event to which I added one additional field event_datetime of type datetime using the text field custom input format as Mo/Da/Year – TimeAM/PM (ex: 10/25/2008 – 11:45am).

Then in views I cloned the default calendar view. I used filter to set Node: Type = Events to remove non-events from my calendar and Content: Event Date and Time (field_event_datetime value) asc to hopefully sort get events to show up on the correct days. I will include a full copy of my calendar view's 'default' settings pain at the end of the post.

This isn't working. Instead I’m getting a great calendar view that shows all of my events nodes on the date the event is created / updated (today) not the date set for the event to occur in the event creation process (some time in the future).

The MySQL table content_type_event shows the values I set when creating my events as field_event_datetime_value and field_event_datetime_value2. Manually editing the created feild and changed feild in the nodes table moves them on the calendar view. In sum it appears my calendar is sorting based on node creation and not event datetime.

Bottom Line: Can someone please tell me how in the world I make views sort based on the correct field?

Views keeps coughing up a huge SQL query that looks like it would be helpful to someone with more knowledge, so here that is:

SELECT node.nid AS nid,
   node.changed AS node_changed,
   node.title AS node_title,
   node_data_field_event_datetime.field_event_datetime_value AS node_data_field_event_datetime_field_event_datetime_value,
   node.type AS node_type
 FROM node node 
 LEFT JOIN content_type_event node_data_field_event_datetime ON node.vid = node_data_field_event_datetime.vid
 WHERE ((node.status <> 0) AND (node.type in ('event')))
    AND ((ADDTIME(FROM_UNIXTIME(node.changed), SEC_TO_TIME(-14400)) <= '2008-10-31 23:59:59' AND ADDTIME(FROM_UNIXTIME(node.changed), SEC_TO_TIME(-14400)) >= '2008-10-01 00:00:00'))
   ORDER BY node_data_field_event_datetime_field_event_datetime_value ASC

I tried just blindly dropping that into phpMyAdmin and got back reasonable results:

nid 	node_changed 	node_title 	        node_data_field_event_datetime_field_event_datetime_value 	node_type
7 	1224949001 	Test Event 1 	2008-11-04 11:36:41 	                                                        event
8 	1224949115 	Event Test 2 	2008-11-25 11:38:35 	                                                        event

This just makes me think that I'm not smart enough to figure views out because it is clearly getting the right info out of MySQL it's just sorting on the wrong column.

Settings from my testcalendar view's default settings tab:

View settings
Tag: Calendar

Basic settings
Name: Defaults
Title: None
Style: Calendar navigation
Use AJAX: No
Use pager: No
Items to display: Unlimited
More link: No
Distinct: No
Access: Unrestricted
Link display: Calendar page
Exposed form in block: No
Header: None
Footer: None
Empty text: None
Theme: Information

Relationships:
None defined

Arguments:
Date: Date (node.changed)

Fields:
Node: Title Title

Sort criteria:
Content: Event Date and Time (field_event_datetime value) asc

Filters:
Node: Published True
Node: Type = Events

Comments

fhsm’s picture

I was able to solve my problem after a bit of time digging around in the source and blindly slamming on the UI. The problem was the Arguments section of the views setup.

Arguments:
Date: Date (node.changed)

Should be switched to
Content: Event Date and Time (field_event_datetime value) (or whatever else you want to sort using.

This was super frustrating. I did a lot of googleing and didn't really turn up anything that got me where I needed to go.

http://support.bryght.com/node/569 and http://drupal.org/node/133341 were somewhat helpful but left out a key detail.

I'd like to write up a bit of documentation for the next newbie with the same problem. Where should I put such a writeup? Here in the forum or elsewhere on drupal.org?

fhsm’s picture

I recently setup an upcoming event calendar on Drupal 6.x. I had a hard time finding instructions so here's my experience...

I did not use the event module because a version for 6.x isn’t out yet; however, there are other reasons not to do so discussed in the forums.

Instead I used:
CCK
Views
Calendar
Date

Download and install the above modules to /sites/all/modules and enable them at Administer › Site building > Modules

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

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

Name = “Group Event”
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 personal 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 you expect to have numerous small events posted.

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. I've added location and contact information for my application and tied those to weather and profiles which is kind of cool (but way beyond this little write up) and testament to how amazing Drupal really is.

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

Administer > Site building > Views
This is where the hurt started for me 6 hours ago...

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

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

Nextshould 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 set the start time of your event instead of the node update time as the argument for the view.

On the Filters panel click the “+” logo 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: 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.

WorldFallz’s picture

wow--- excellent writeup. you should definitely make this a handbook page for the calendar/date modules.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

Daniel Berman’s picture

Thanks for the writeup fhsm! Two questions.

- Any ideas as to how the procedure changes for handling multi-day events, especially in terms of displaying properly within the calendar view?

- For an international audience, whats the best way to handle a timezone field?

The reason I am asking is because, I am trying to set up an international events calendar, on my site, www.issacharnetwork.org/calendar. I need people to be able to enter the local time of their event, but have the time properly converted for others who may be joining the event electronically from different timezones.

My inituition, would be that I would need the event's location, the user's location, and the internal server time to anchor the calculations. So then, if the event location could be picked up by the location module. I would just need the other two data points, and then run it through views properly. Am I heading in the right direction, or right off a cliff?

Daniel Berman’s picture

knaa’s picture

This was very helpful for me, particularly the part about setting the start time of an event in the calendar, instead of the update time. I wonder why the module maintainer have it set to the update time by default. I guess everyone has different uses for a calendar. Like you, I use it primarily for upcoming events.

Thank you for the excellent write-up. I agree this write-up should become part of the Calendar handbook.

justageek’s picture

Here are a couple of ways to use the repeating-date api with the event calendar as described in your post, note, you will have to choose the one that fits based on caveats listed.

When created your event_date_time field, choose the option to automatically include a 'To' field. Drupal will add a second field, so you can enter a From and To date. Also, when adding your field using CCK, for the Widget Type, make sure you choose one that includes "repeat options. This allows you to indicate how your event repeats, there are many, many great ways to repeat dates

Caveats with this method - If you create a date that starts on 10/28/2008 at 3:00PM and the To date is 10/31/2008 at 4:00PM, the calendar view will basically show the date 10/30/2008 instance of your event as All Day. In other words, Drupal assumes that your date starts at 3:00 PM on 10/28 and ends on 10/31 at 4:00PM. So, if you are wanting to show, say, a training class that goes from 1:00 PM to 3:00 PM each day, this will not work properly.

So, to create an event like this training class, you should create a single event that starts on 10/28/2008 at 1:00 PM and ends on 10/28/2008 at 3:00PM, then use the "repeat" feature to repeat the event until Nov 1. You need it to repeat until Nov 1, because apparently the end date for your repeat is not included, so it causes your class to show on 10/28,10/29, 10/30, and 10/31. NOTE: the start and end times only show on day 1, which would be the 28th.

So, you need to figure the following before you do your work:

Do I need to use the repeat function to repeat single days within an event, where the days have their own start and end time, or do I need to repeat events throughout the years, such as monthly meetings or something like that.

The cool thing is, there are a bunch of ways to do all this stuff, you could create separate start and end time fields and make your event date field the date portion only, this would give you more flexibility.

I hope this helps someone, my experiments have really enlightened me.

UPDATE:
I think that it is much more flexible to store your event start and end times in separate fields. You can create multi-day events that also repeat throughout the year this way.

zilla’s picture

if node is same and only date changes and does not specifically 'repeat at same time' AND you don't want that big nerdy 'repeat interface' that scares users, you can use cck unlimited on just date element in event custom type, details and write up here: (somebody oughta pull this all into a handbook page!)

http://drupal.org/node/317844#comment-1046675
(question related to a movie theatre with movies (where title/body stays the same) and many 'show times' that may or may not repeat...but need to come up in a view (calendar, block, page, etc) - also quite detailed for a new user...
........................................................................
i love to waste time: http://twitter.com/passingnotes

elektro’s picture

Thanks for this great howto!

I have the same problem when I use date with repeats. My block shows the same events.
I can't use the CCK unlimited setting because I use the jQuery input format and not the "text field with custom input format".

I would need a solution that makes the view distinct by the node id.

Thanks.

axtolf’s picture

I used this guide to create an event calendar. Thanks to the author for this guide!
Now I need to personalize for my site and I'm working about theming, but this is not the problem. I've read almost all the comments and read the links, but, probably due to my poor practice with drupal, I dint' understand how to make an event repeat in the time.
My need is to repeat an event monthly or yearly.
This is because I'm using it not only as event calendar, but as anniversary calendar. So in same dates, I'll have the same "event" (anniversary) forever and for all the next years.
It's not clear, how I can do it... there is a nice guy that explain in poor words me how to do it? Thanks.

Sloane DellOrto’s picture

fhsm - Can't thank you enough for taking the time to write these instructions ... have been too afraid to try this module until now, and thanks to you I have a calendar up and working perfectly! This knocks the socks off of Events in many ways - thank you thank you thank you! And of course a HUGE nod at Earl and everyone else involved with Views. This is just damn cool stuff, even if I don't understand half of it. ;-)

bixwilson’s picture

fhsm, thank you for putting this guide together. I had installed all those modules and was trying to get my View running, but I wasn't using the default calendar view. You helped me get back on track.

BUT, now that I've followed your instructions and set up the calendar view, the preview is broken....I'm getting a message that says "An error occurred at /acdrupal/admin/build/views/ajax/preview/classes_calendar."

The preview is not working, and the path to the view, /calendar, brings up a blank page.

Do you or anyone else know anything about this ajax error?

Thanks.

justageek’s picture

I had the blank page suddenly happen, and by turning on php errors, I found that the calendar is calling a missing function in the Date module, the latest dev version of the Date module has it in there. Since these are still actively developed, I think this might happen from time to time. Try upgrading the Date module and see if the blank page issue is fixed.

danimagoo’s picture

Thank you so much for this, I was trying to use the Events module and it wouldn't do everything I needed. Views has always intimidated me a bit. Your step-by-step instructions worked perfectly. Thanks!

kwgossett’s picture

fhsm - this is awesome. In addition to the Handbook, see if they will include the code in the Advanced Help module as an example - typically found at example.com/admin/advanced_help/views?popup=1

I'm not sure if you would ask the maintainer of Advanced Help or views (merlinofchaos) or the maintainer of Calendar (KarenS)...still, I'm sure it has a place among their current examples.

Thanks!
kelly

Dr. Rhomboid Goatcabin’s picture

Love the calendar, and now I want to get fancy. Any thoughts on how to change the background color of a date on the calendar based on the content of a field in the event node?

I'm building a calendar for a sport league and added a field to the event (called event_type) that is a radio button with the options of Home, Away, or Other.

I'd like to make the background of the date change color based on the event_type field (ie. days of home matches would have a blue background or whatever).

Any ideas?

Dashingly,
Dr. Rhomboid Goatcabin

richard.e.morton’s picture

Did you get a reply or discover an answer to this colour issue with calendar? I have found a patch for calendar 5.x but not 6.x and it really would be a cool feature so that it is easier to understand, like the event module.

thanks

Richard

Fayna’s picture

see this page in the Date/Calender documentation:

http://drupal.org/node/316420

it describes "Legend Colors," which can be used for certain taxonomy terms, vocabulary, or content types.

francis55’s picture

I used the following CSS for the month calendar in my project. Hope this can help:
* today without events: white on light blue-gray
* today with events: white on orange background with black border
* past events: faded orange background
* future events: brighter orange background

/* Calendar */
table .mini-day-on a {
text-decoration: none;}

.block .calendar-calendar .month-view table tr td {
font-weight:regular !important;}

.block .calendar-calendar .month-view table tr td.today.has-events {
background-color: #DBA84E;
border: 1px solid #666666;
color: #FFFFFF;}

.block .calendar-calendar .month-view table tr td.today {
background-color: #ABBBCC;
color: #FFFFFF;}

.block .calendar-calendar .month-view table tr td.has-events.future {
background-color: #DBA84E;}

.block .calendar-calendar .month-view table tr td.has-events.future a {
background-color: #DBA84E;
color: #333333;}

.block .calendar-calendar .month-view table tr td.has-events {
background-color: #EBCE9C;}

yoda-fr’s picture

Hey all,
is anybody here know if is it possible to hide all the views week, year,.. and to make a direct link to the article from the calendar displayed.
Thanks for your help!

kurosevic’s picture

Hey fhsm,

your tutorial kickstarted my learning of views. thank you very much.

I've started creating variations of what you taught me with your tutorial, and and the calandar clone view you helped me create works well, however now i need to disable it because i have another one doing the same thing.

how do i disable it?

MrBT’s picture

One problem I'm seeing is when I add something to a date, say today, and that thing happens in 2 months, then that thing shows up both today (where I don't want it) and again in 2 months (where I do want it).

What am I doing wrong?

pzula’s picture

In your arguments Date: date(node) make sure under Date field(s): that you uncheck "Node: Updated date" and leave "Content: date_field" selected. Then it will only show up on your event date.

scrowder’s picture

Must be missing something simple for a post to only show on the date it is posted and not the intended future date. What have I missed in Views?

No problem - post from Steve below clarified this. Attach to Node being the trick

kurosevic’s picture

Does anyone know how to extend this event with an RSVP option?

I was thinking of making a custom poll that was selected in VIEWS and then just making it in the format

Q: Attending?
A: Y/N

while inheriting the event date as the time when the poll would close.

HOWEVER, I CANNOT FIND A SINGLE WAY TO MAKE A POLL INTO A CUSTOM NODE. Anyone know how?

adamwebb’s picture

Take a look at the SignUp module.

ulf1’s picture

Use the RSVP module for invitations,
and use the views/calendar to show the events.

~
Ulf

tannerg’s picture

This is a really great write up that saved me hours upon hours of fiddling around with these calendar view arguments and what not I'm sure. Thanks fhsm for sharing this with the community.

The thing I'd really like to get out of this tool is for the calendar to display in week and day view with the hours of the day laid out. So, for example when something is happening from 12:00 - 15:00 you can see the rest of the day is open. This would be the final punch as far as I'm concerned to making this thing viable for a long list of solutions. Has anybody got it to do that yet?

ortizmj12’s picture

First off, great write-up, fhsm! Very easy instructions to follow and work like a charm. I've just got one problem...

I've created a test event to make sure it was all working. I've noticed that when I bring up my calendar in a day view to look at my test event, the enlarged time in the left column does not match the start time for the event. Reference the link to see what I mean:

http://i36.tinypic.com/zo86yc.jpg

Anybody know how to fix this? Thanks in advance! :)

atuline’s picture

This was a well written tutorial and I was doing great with a fresh/latest install of D6 (with 2.0 rc5 of date and calendar modules and CCK 2.1 and pathauto). I created an event content type and an article of that content type.

The problem started with the arguments panel in step 3.

The tutorial says:

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)

I'm sorry, but there was no entry called Content: Event Date and Time (field_event_datetime value), nor any other 'Content' options.

At this point, the tutorial fell apart on me since I had no field to check.

Update: Also tried the latest dev versions of CCK, Date, Calendar, Views with similar results.

layoric’s picture

Also didn't have the field_event_datetime value options listed. What gives?

ortizmj12’s picture

Did you make sure to create the new field after you created the new content type? Only thing that comes to mind right now...

atuline’s picture

One important item missing from the original article was to add the Field to your Calendar View. So, prior to adding the argument as outlined in Step 3, you need to add the Field. So, while editing the new Calendar View I went to the 'Fields' selector and:

Click Add and select the following:

Content: Event Date and Time (field_event_datetime value) Default

Once I did that, the argument will now work as described.

jimmb’s picture

Hi atuline,

Thanks for pointing this out! Unfortunately, though, I'm still not seeing "Content: Event Date and Time" as an option in the "Fields" section of the Edit View area. In fact, there is no "Content" group or options at all. It goes from Comment (lots of options) to Global (1 option) to a bunch of Node options and so on.

I do have the date and time field set up as described, and it's working as I made a test event and it was there. So I can't figure out why I can't add this in the Fields area :( Any suggestions will be greatly appreciated!

Jim

pzula’s picture

Perhaps you did not add a new field to your Event node that included a date widget?
If your event node does not contain a way to enter a date, this option will not show up as a field in the Views.

wanderingstan’s picture

I had the same problem, but turns out it was user error. If you click the '+' option next to 'Arguments', there will be no Content fields listed. However, if you click the "Date: Date (node.changed)" (first line in the Arguments sections), then you can scroll down and select your Content date field.

brecko’s picture

I followed all the steps. The Calendar itself works great.

However, when I click on the date of the event that was created in step 2, the calendar page for the day of the event comes up but it is empty.

Shouldn't the text of the event I created appear here? What am I missing?

breck@astorholdings.com

ortizmj12’s picture

What does your fields section look like for that calendar view?

leonewski’s picture

followed all the steps. The Calendar itself works great.

However, when I click on the date of the event that was created in step 2, the calendar page for the day of the event comes up but it is empty.

Shouldn't the text of the event I created appear here? What am I missing?

please help
doctor.rocket@web.de

dennots’s picture

Thanks for the excellent guide. It really showed me how to use the Calendar / Views.
This should definitely be added to the module help.

hujia’s picture

Hello there,
Thanks for your excellent and detailed write-up! It serves for me both as a tutorial/learning documents and also very pragmatic instruction. I followed your instruction as given above carefully and closely to the letter for twice. I think i have succeeded in setting the Calendar in working nexus with the Event content and View correctly, with only one exception:
1) all the events I entered, like 12-26 and 12-25 (following the format given) all fell on the same day 12-06-2008 which is today as i type, regardless the FROM and TO times that I created for the Events. I checked the mysql, there are correct, in format of 2008-12-25 00:00:00.
2) The Events' titles show up correctly on the Calendar (though again on the wrong date). But, when I clicked on any of the events, which erroneously fall on 12-06, there is no description or detail which I typed. I am not sure if this is because the dates are wrong for Calendar in the first place? I tested the sql query for Views for these times, and they resulted in the correct times. but in Calendar, there are incorrect.

I am sure where goes wrong? Appreciate if you could help!

thanks in advance, hujia

hujia’s picture

For the problems I reported here I found that the events are all located on the calendar according to their POST DATE, not FROM and TO dates. I check the setting for View and the event content type I created, as well as data for event, esp. FROM and TO, and cannot detect obvious wrong place... So if you could help me with this.

UPDATE: Hello, I would like to append this piece of information that may help for the user like me. What I found is there is a lacuna, or a missing step, maybe an important one at least for me, for the nice write up for setting the calendar up. It is the "Fields" configuration. Here is what I found as a necessary step to make the Calendar work: You need also, in addition to all the instructions given, to do the following forthe "Fields":
1. Click Add ... for Fields, and select the following:

Content: Event Date and Time (field_event_datetime value) Default
Content: Event Date and Time (field_event_datetime value2) Default

2. Delete (remove) the default item "Node: Published"

That would solve the problem I encountered. Hope that may help for somebody.

Best hujia

penteri’s picture

I've got the same problem as you: all my events' starting time fell on the current moment I was watching them. For example: an event's starting time is 2008-01-29 00:00:00 and ending time is 2008-01-29 01:00:00. If I check out the calendar for that event there is for the starting time current moment 2008-01-28 14:36:00. Ending time is however correct 2008-01-29 01:00:00.

My solution: In Calendar view's Fields-panel there were
1. Content: Event Date and Time (field_event_datetime value) Default
2. Content: Event Date and Time (field_event_datetime value2) Default.

I remove the first one
Content: Event Date and Time (field_event_datetime value)

When I check out the calendar for that event starting and ending time are correct
2008-01-29 00:00:00 - 2008-01-29 01:00:00

Nathaniel Wolfe’s picture

http://arhmedicalexplorers.com/calendar

So, the calendar posts events by the day they are posted instead of the day the event is taking place. Also, it likes to publish everything. Would anybody have the answer?

E-mail: nathan@akzombies.com
AIM: Badwolfx31

poobah’s picture

I get to step 3
"Enable the Default Node view: calendar (Calendar)
Clone the default view"

I don't see that as an option, mine goes from

Default Node view: backlinks (default) Enable
Path: node/%/backlinks
Block, Page
Displays a list of nodes that link to the node, using the search backlinks table.

to

Default Comment view: comments_recent (default) Enable
Title: Recent comments
Path: comments/recent
Block, Page
Contains a block and a page to list recent comments; the block will automatically link to the page, which displays the comment body as well as a link to the node.

ortizmj12’s picture

Did you enable the "calendar" module?

deverman’s picture

I also can't find this default view that is talked about. I have the module enabled. I have upgraded from a drupal 5 site where I have converted a views 1 view that did upcoming events without the calendar module. I want to add the ability to download the calendar as an ical file but I cannot find the ical display option anywhere. i wanted to try the date tools wizard but it requires that the date file not already exist in the content type and I want to use an existing content type with an existing date field.

The only date related display I can find in the views list is the "Date Browser".

bobwhitleyjr’s picture

When I go to create the content on Step 2 I get the following error.

warning: Missing argument 3 for content_permissions_field_access() in /home/whoyou/public_html/cms/sites/all/modules/cck/modules/content_permissions/content_permissions.module on line 21.

Did I miss something on the cck install/Setup?

Thanks for any help.

ternto333’s picture

You saved my bacon

seanmalley’s picture

This method worked perfectly for me, thanks for the well written instructions! I do have one question though...when I was entering a test date into the calendar, it appeared like the time was showing up incorrectly in the calendar view for me, but showed correctly when clicking on it. After some messing around with it, I figured out it was just displaying the time I "created" the actual event on the calendar, not the time of the event. Is there any way to remove this, or at least have it show the event's actual time on the calendar instead?

crmanski’s picture

Thanks for this. I was about to go through the steps and noticed that the "Date Tools" module has a wizard that sets up the calendar for you with the correct options. I found this under Administer > Content management > "Date Tools"

gbcomputer’s picture

How to put the little calendar on all pages, for example, calendar on right navigation block.

gbcomputer’s picture

disregard, I found it....
thanks sooo much for tutorial

must add to right block.

gbcomputer’s picture

I got mini view of caledar to show, but the sunday is at end of week, need to move to first day of week.

also, how to get the mini view of calendar to stay within limits of right block column, it is extending passed it. IE6 IE7.

also my drupal site does not display well in IE 6, the calendar wraps to left column :(.

any help would be great

thanks

gbcomputer’s picture

Thanks saw the configuration-date/time.
resaving works, thanks for the post here.

my other problems are still pending, hellllllllp. I know these will be tough to fix.

Anonymous’s picture

This has helped me set up an event/calendar and also to troubleshoot where another wasn't quite working. Kudos.

Did it ever get written up in the documentation? Or even better, for those who come after, packaged as a 'feature'?

gys’s picture

im so thankfull - u saved my day!

attilahooper’s picture

Most excellent write-up for sure, I love these things. But I'm having some problems and I'm not really sure if it's because I have newer releases of the various packages.

At this step (3):

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)

Me:
I click Arguments Date: Date (node)
I uncheck "Node: Updated date"
Notice the change in syntax, from update to updated. Not a problem, but a clue that things may have changed since this write-up or its a typo.

Here's the problem

I cannot find a single instance of
Content: Event Date and Time (field_event_datetime value)

It seems to have been replaced with From To date field

Content: Event Date and Time (field_event_datetime) - From date
Content: Event Date and Time (field_event_datetime) - To date

If I select any combo of the two above and update I get a series of errors;

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.

Thx in adv.

Panaromic.webdesign.com’s picture

I have exactly what you have. I am also using the latest versions of all concerned modules.

Clarification: field_event_datetime_value and field_event_datetime_value2 are column names used in the DB tables for 'From' and 'To' date fields.

I took a closer look at the SQL generated by the Views module. It looks like "(field_event_datetime value)" was replaced by "(field_event_datetime) - From date" in the most recent versions of modules. Even replacing in the Step 3 instruction with the latest "(field_event_datetime) - From date" field name does not display any output.

I have to get this working for one of my projects, I will post my solution if I come up with one. Any help from others will be appreciated.

PS: I tested the Views generated SQL query by embedding it in my page content type it gives output, there may be something going wrong with 'Calender Navigation' style also, but first we have to see some output from the Views SQL query.

mashik’s picture

I have 2 problems with repeating events.
1. Only first date for the repeating events get underlined in the calendar view.
How to get all dates be underlined?
2.When I go to the event from any date I see the whole list of dates.
How to limit the date shown only to the date for which user wants to see the schedule?

ronalddevos’s picture

Hi,
Having the same problem: every event date contains a list of every event dates...
Did you find a solution to this problem?

mashik’s picture

No, I have not. I had to remove the date field from display.

Nathan Obral’s picture

I followed the steps provided here, installing the following modules into my Drupal 6.16 setup:

- CCK (cck-6.x-2.6)
- Views (views-6.x-2.8)
- Calendar (calendar-6.x-2.2)
- Date (date-6.x-2.4)

After doing so, the drag-and-drop handles crosshairs interface disappeared from my Administer >> Blocks page.

I uninstalled all four modules until I can figure out what in the hell is wrong, but that didn't make a difference. I even went so far as to delete everything from those four modules. Nothing. Even switching to other themes doesn't work; the crosshairs may appear one time, then vanish the next!

Supposedly there's a "Theme Developer" option that can be disabled in order for drag-and-drop to work again, but I'm just a n00b to Drupal that has no idea how in the hell to do that, or what file and filepaths to go. If it wasn't in those four modules, how was it installed? I never remembered installing a "Theme Developer" or anything like that...

I need help ASAP... I'm totally lost. What did I do? Was there a compatibility issue? And where do I go? How do I fix this? I need help!!! :'(

miaoulafrite’s picture

how would you filter past events?
the view would only display upcoming events.
thanks

Katharine_Gates’s picture

Hi, just made a calendar this way, maybe I can help.
In the filter area of views, add Date: Date Node.
Then you can go in there and set Start Date (field_start_date) >= now.

-klg

Now I just have to figure out how to have it spit out events (mine are museum exhibitions ) that don't have an end date as "Ongoing"...

bruindelts’s picture

Sorry to resurrect such an old post, but how does one go about selecting Datetime as the field type? The only ones available to me are Decimal, Float, Integer, and Text.

bruindelts’s picture

Oops, nevermind, got it. "As soon as you ask..."

I had to enable the Date module, not just the Date API (as listed here).

gripmedia’s picture

I have updated these instructions from FHSM (which are a lifesaver BTW) and included the fix from BOFH_UK here.

Included are options that add a time-picker, fixes the "Arguments" error (thanks BOFH_UK) and makes the iCal export feed work correctly.

-gripmedia

cdragin’s picture

I followed the instructions but get this error after adding the sort criteria:

user warning: Unknown column 'node_data_field_datetime_field_datetime_value' in 'order clause' query: SELECT node.type AS node_type FROM node node LEFT JOIN content_type_event node_data_field_datetime ON node.vid = node_data_field_datetime.vid LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid WHERE 0 ORDER BY node_data_field_datetime_field_datetime_value ASC in /home/icatri/public_html/drupal/sites/all/modules/views/includes/view.inc on line 727.

Seems to work without adding any sort criteria, so I will remove it and hope for the best.

cdragin’s picture

oops, sorry for the duplicate entry

Dr. Rhomboid Goatcabin’s picture

Tremendous write-up -- I would've been flailing in vain for hours, however I ran into a problem. When finished, my calendar shows the week running from Monday thru Sunday (any way toi change to Sun thru Sat -- I couldn't find anything for this, but I'm new to this module).

Also, it shows that Nov 1, 2008 is Sunday (when its really Saturday all dates are offset by +1), and the pink highlighted box indicating today (I think), is on Nov 2, 2008 (when its really Nov 1, 2008).

How I can fix...?

Dashingly,
Dr. Rhomboid Goatcabin

Dr. Rhomboid Goatcabin’s picture

If anyone out there sees the same thing, all I did to fix was wander into Administer>>Site Configuration>>Date and Time. I had set all this originally, and when I went there, I didn't change anything, just apparently had to open and save again.

Again, kudos to fhsm, brilliant write-up -- thanks for letting everyone benefit from your experience.

Dashingly,
Dr. Rhomboid Goatcabin

dugh’s picture

If you want to just show upcoming events, remember to filter by event dates >= now

I created an upcoming events block using date/calendar/views2, see:
http://itls.usu.edu/calendar/upcoming
http://itls.usu.edu/ (block on right)
http://itls.usu.edu/calendar (regular calendar view)

The one extra thing I did was give each group their own calendar, and let people filter the calendar view by group. To do this I had to hack og, the simple patch wasn't understood by the og maintainer:
http://drupal.org/node/279942#comment-913175

justageek’s picture

Your site / example is great. My calendar view uses the dhtml / ajax popups when you click and event, and I can't quickly figure out how to turn that off.

Good stuff, though.

Dr. Rhomboid Goatcabin’s picture

I'm no expert, but I think I know the answer, on your Module page, under the 'Date/Time' twistie, disable 'Calendar Popup'. That's how I did it at least.

Dashingly,
Dr. Rhomboid Goatcabin

zilla’s picture

sorry, not meaning to hijack this issue BUT i am trying to do exactly what you're doing with those tabs on your groub home pages - is that via a module? could this also be done with tabs in views? i'm still having trouble with both....

thanks in advance for any insights ;)
........................................................................
i love to waste time: http://twitter.com/passingnotes

dugh’s picture

Yeah use the special $group argument like so:

Check provide page view.

Set the url of the page view:
node/$group/calendar

Under the 'menu' section check
'Provide Menu'
and
'Provide Menu as Tab'
(or at least the 2nd one?)

Set the menu title ('Calendar') and so forth.

In the arguments section, make the first argument:
OG: Group nid(s)

I am using drupal 5 on that site, I haven't tested group tabs in drupal 6 yet. I hope they still work.

vjordan’s picture

dugh - you have a very clean looking theme there. Well done.

Can you explain how you did the upcoming events listing? Is it a single block view used in both the right sidebar and on calendar/upcoming? Did you base the view on a cloned calendar view or did you craft the view from scratch? If the former, could you explain how you eliminated the calendar navigation information - through theme changes or view configuration?

If you crafted from scratch, how did you configure it so that repeat events are shown with the correct date? I've tried this approach and can't get repeat events to list against the repeat dates - I only seem to get the date of the first event.

dugh’s picture

The upcoming block and page is a new view.

The block is a table view with these fields:
Node:Title
and Date: Date (field_eventdatetime in my case)

I filter by
Node Published = yes
Node: Type = my event node type
Date: Date - Date (field_eventdatetime) is greater than or equal to now (actually 'now-1day' so events don't disappear the instant they start).

And I sort by:
Date: Date (field_eventdatetime) ascending

I'm not sure how to fix the repeat date issue. I would create a new support request for the date module, and KarenS or someone can likely help.
But look through the calendar and date configurations for help too.

jeremy_a’s picture

Dugh, can you explain how you achieved both putting your main calendar at www.site.com/calendar & then Upcoming at www.site.com/calendar/upcoming? I'm trying to replicate this pattern but the main calendar view overrides the upcoming because the view expects site.com/calendar/2008-11 as an argument, not "upcoming"

Cheers

dugh’s picture

Sorry, I don't know why it wouldn't be working for you.

A few things (just grasping at straws):
-My argument looks like /calendar/2008/11 not /calendar/2008-11
Don't know if that makes a difference.
-Maybe the order of the views or the order of the URL aliases (/admin/build/path) has some effect, I don't know.
-Also, I am using global redirect, which forces one alias per page/node/view.

vjordan’s picture

Thanks for the details dugh. I see ITLS is built on D5. I'm tackling this problem on D6, views2 and it works somewhat differently.

In the meantime I've discovered KarenS has done some work here (http://drupal.org/node/290365#comment-1064092). I've downloaded the dev version which includes a default "upcoming" block. Not helping a lot (yet) as I'm getting WSOD but hopefully I'll be able to troubleshoot that.

netentropy’s picture

can someone provide a working view that lists entries by the time they are put on and not the time the node was created?

ashley.maher@didymodesigns.com.au’s picture

Thanks for the above howto.

I had the calendar working very rapidly.

However after spending quite a few hours over a cuople of days I am clearly not doing something correctly in the Upcoming Block View.

I have set the date format to be dd/mm/yyyy. This works throughout the site, and in the views calendar. However no matter what I do the date of the event in the upcoming is registered as mm/dd/yyyy. I even removed the modules and started form scratch, more than once. I have emptied the cache tables. I just really do not know what to try next. This is clearly my fault. As everything else just works i have no idea what I mucked up.

Thanks to anybody with suggestions.

Regards,

Ashley

dugh’s picture

I upgraded the date and calendar modules the other week, and not repeating dates just show the first instance. So now my upcoming events block is broken. I reported the bug here but nothing came of it:
http://drupal.org/node/352753

I usually test it out first on a staging site, but our server admin had everything else down.

When I upgrade to drupal 6 this summer, I'm probably going to just use the event module instead. It appears to be more stable now (although 6 months ago the reverse was the case).

kwgossett’s picture

@Dugh

My Filters look like this:

Node: Type = Event 
Node: Title != something_I_wanted_excluded 
Date: Date Content: Start Time (field_time value) >= now - 1day 
Node: Published Yes 

yet, my upcoming events view still shows past events.

I notice that you have:
Date:Date - Date (field.....) vs. my
Date:Date Content: Start Time (field....).

I've got no idea what's going on, or how to remove past events :(

Any ideas?

dugh’s picture

you may need to clear your views cache - go to the tools tab under views to see a button to clear the cache.

or check for typos perhaps? like "now - 1 day" instead of "now - 1day" which might not be parsed correctly perhaps

ulf1’s picture

I have the same issue, that older events still show up.
Clearing the cache did not help.

Interestingly if I display the query, like followed, it replaces "now" with '2008-11-01', and that causes the problem, but I am not sure how to tell the view module to use the current date .

Thanksm
Ulf

SELECT node.nid AS nid,
node_data_field_startdate.field_startdate_value AS node_data_field_startdate_field_startdate_value,
node_data_field_startdate.field_startdate_value2 AS node_data_field_startdate_field_startdate_value2,
node_data_field_startdate.field_startdate_rrule AS node_data_field_startdate_field_startdate_rrule,
node_data_field_startdate.delta AS node_data_field_startdate_delta,
node.title AS node_title,
node_revisions.body AS node_revisions_body,
node_revisions.format AS node_revisions_format,
node_data_field_startdate.nid AS node_data_field_startdate_nid,
node.type AS node_type,
node_data_field_highpriority.field_highpriority_value AS node_data_field_highpriority_field_highpriority_value
FROM calheat_node node
LEFT JOIN calheat_content_field_startdate node_data_field_startdate ON node.vid = node_data_field_startdate.vid
LEFT JOIN calheat_content_field_highpriority node_data_field_highpriority ON node.vid = node_data_field_highpriority.vid
LEFT JOIN calheat_node_revisions node_revisions ON node.vid = node_revisions.vid
WHERE ((node.type in ('calheatevent')) AND (node_data_field_highpriority.field_highpriority_value <= 2))
AND (DATE_FORMAT(ADDTIME(node_data_field_startdate.field_startdate_value, SEC_TO_TIME(-28800)), '%Y-%m-%d') >= '2008-11-01')
ORDER BY node_data_field_highpriority_field_highpriority_value ASC, node_data_field_startdate_field_startdate_value ASC

Nimo’s picture

I have got the exactly same problem. The SQL-query replaces now with '2009-01-01' instead for current date. Has anyone found any solution to this problem yet?

stephenh’s picture

Hey Nimo,

Did you find a solution to this problem yet? I am ha ving exactly the same issue - perhaps it has something to do with working on a localhost?

WorldFallz’s picture

FYI this is a known issue that has been fixed in the current dev release. Whenever you encounter a problem, your very first stop should be the module's issue queue. ;-)

cloneofsnake’s picture

You have a really nice and function calendar there! I would like to replicate what you have. My current problem is, I have a very long list of node titles on the calendar page before the actual calendar! This is also for a school, so some classes repeat themselves twice a week at different hours of a day for 3 months. Therefore, I have 2 different datetime field for the "class" content type, and then I have an event content type with an event start time.

So... how do I make the calendar show all the classes and events coming up, while not showing a list of duplicated node titles (class 101 - chemistry, repeated 30 times) above my calendar? My view query:

SELECT DISTINCT(node.nid) AS nid,
   node_data_field_datetime.field_datetime_value AS node_data_field_datetime_field_datetime_value,
   node_data_field_datetime.field_datetime_value2 AS node_data_field_datetime_field_datetime_value2,
   node_data_field_datetime.field_datetime_rrule AS node_data_field_datetime_field_datetime_rrule,
   node_data_field_datetime.delta AS node_data_field_datetime_delta,
   node_data_field_datetime2.field_datetime2_value AS node_data_field_datetime2_field_datetime2_value,
   node_data_field_datetime2.field_datetime2_value2 AS node_data_field_datetime2_field_datetime2_value2,
   node_data_field_datetime2.field_datetime2_rrule AS node_data_field_datetime2_field_datetime2_rrule,
   node_data_field_datetime2.delta AS node_data_field_datetime2_delta,
   node_data_field_start_date.field_start_date_value AS node_data_field_start_date_field_start_date_value,
   node_data_field_start_date.field_start_date_value2 AS node_data_field_start_date_field_start_date_value2,
   node.title AS node_title
 FROM node node 
 LEFT JOIN content_field_datetime node_data_field_datetime ON node.vid = node_data_field_datetime.vid
 LEFT JOIN content_field_datetime2 node_data_field_datetime2 ON node.vid = node_data_field_datetime2.vid
 LEFT JOIN content_type_event node_data_field_start_date ON node.vid = node_data_field_start_date.vid
 WHERE ((node.status <> 0) AND (node.type in ('course', 'event')))
    AND ((DATE_FORMAT(ADDTIME(node_data_field_datetime.field_datetime_value, SEC_TO_TIME(28800)), '%Y-%m-%d') = '2008-12-03') OR (DATE_FORMAT(ADDTIME(node_data_field_datetime2.field_datetime2_value, SEC_TO_TIME(28800)), '%Y-%m-%d') = '2008-12-03') OR (DATE_FORMAT(ADDTIME(node_data_field_start_date.field_start_date_value, SEC_TO_TIME(28800)), '%Y-%m-%d') = '2008-12-03') OR ((DATE_FORMAT(ADDTIME(node_data_field_datetime.field_datetime_value, SEC_TO_TIME(28800)), '%Y-%m') <= '2009-03' AND DATE_FORMAT(ADDTIME(node_data_field_datetime.field_datetime_value2, SEC_TO_TIME(28800)), '%Y-%m') >= '2009-03')) OR ((DATE_FORMAT(ADDTIME(node_data_field_datetime2.field_datetime2_value, SEC_TO_TIME(28800)), '%Y-%m') <= '2009-03' AND DATE_FORMAT(ADDTIME(node_data_field_datetime2.field_datetime2_value2, SEC_TO_TIME(28800)), '%Y-%m') >= '2009-03')) OR ((DATE_FORMAT(ADDTIME(node_data_field_start_date.field_start_date_value, SEC_TO_TIME(28800)), '%Y-%m') <= '2009-03' AND DATE_FORMAT(ADDTIME(node_data_field_start_date.field_start_date_value2, SEC_TO_TIME(28800)), '%Y-%m') >= '2009-03')))
   ORDER BY node_data_field_datetime_field_datetime_value ASC, node_data_field_datetime2_field_datetime2_value ASC, node_data_field_start_date_field_start_date_value ASC

Also, how did you get the

links out? I couldn't find it in the view's options.
lenin’s picture

I was trying to filter the view, like you said, but it doesn't seem to work for me. I am a real newbie and find the process of customizing views in Drupal the most frustrating experience of my life! Can anyone guide me though this process, please.

jewhite’s picture

First of all .. great write up. Breaks it down nicely ... but not too simple to obfuscate what *can* be done ...

My Time zone was 5 hours off (I'm at GMT -5 ... EST) in the display of events. The machine is set to American/New York (EST), Drupal is set to America/New York, User is the same and the event is posted as America/New York. Whenever I saved an event, it incremented the time up 5 hours (to GMT). I turned off user configurable time zones and now it holds time correctly. Anyone else experienced this or have an idea as to why?

Cheers!

fhsm’s picture

Hi All -

Looks like this thread hit a bit of a nerve with people. I've had a number of folks send me messages asking particular questions. Unfortunately I included 100% of what I know about this problem. Sorry to not be more help. Perhaps someone more active in the involved projects could document this use. Mine should not be the definitive word on how to accomplish this.

beg’s picture

Hi,

While configurating the event page I run into some new questions:

How can I support the creation of repeating events with cck/date/calendar/event modules? e.g. similar events every week, same day, same time. I have to have the possibility to create day/time once and say to repeat every weak, since it's no option to do that for every week manually.

and/or is there any possibility of "saving" kind of templates for events in order to save basic information of a repeating event and just creat a new entry by adding date/time information?

Background is a calendar for new and repeating events. (different events each of them being the same event, same description, weekly with some breaks for holidays..)

I also tried to get different colors for the different events with the node.color module, which would be very usefull. I created different event types with different colors, but they still dont show up in different colors in the Calendar..

thx,
Bernhard

dugh’s picture

In Drupal 5, repeating events broke 3 months ago, and bug reports for the drupal 5 version of the date module are pretty much being ignored now.

If you are stuck like me, you'll have to downgrade to a version of the module before November 2008.

cloneofsnake’s picture

Thanks for this excellent write up! I definitely saved me a lot of headaches!

I have a slight problem with repeating dates, see I'm trying to create a site for a school, the school offers classes which repeats 2 or 3 times a week at different hours. eg: Mon 2 - 3pm, Wed 7 - 9pm, Fri 4 - 6pm. This schedule goes on for a quarter (3 months).

The "Repeat" options in Date seems to be only limited to repeating on different days at the same hours. The only way I can think of to do the "unlimited" entries, and manually add each day's lesson for the whole 3 months!!! Needless to say this is a pain! Is there any way you can think of that can solve this problem and allow an auto "repeat"?

The other way is to create multiple datetime fields, say one that repeats the Mondays, another repeats the Wednesdays... etc etc. But I don't think that's a good idea. I think it makes more sense to keep it at just 1 datetime field.

Please help.

notebene’s picture

subscribe

aac’s picture

Subscribing!!!

---~~~***~~~---
aac

kimaldis’s picture

I'm having problems here changing the argument to event_datetime; I can't find this field but I can find two fields, 'value' and value2'. These two fields seem to be tied to the new datetime field in my event content type because if I add another field I get two more and if I delete the field I no longer have these available to me when I come back to change the argument.

Does this ring any bells with anyone? I'm using Drupal 6.10

thanks.

kimaldis’s picture

OK, the two named fields, field and field2, make sense now, one would be the start, the other the end date. and the query looks OK but still the event I create doesn't appear in the calendar view. There seems to be some kind of trouble with my custom field because stuff appears when I use, say, a modified date.

my query more or less seems to make sense.

ELECT node.nid AS nid,
node.title AS node_title,
node.changed AS node_changed,
node.type AS node_type
FROM node node
LEFT JOIN content_type_calendarevent node_data_field_event_date ON node.vid = node_data_field_event_date.vid
WHERE (node.status <> 0)
AND ((DATE_FORMAT(node_data_field_event_date.field_event_date_value, '%Y-%m') <= '2009-03' AND DATE_FORMAT(node_data_field_event_date.field_event_date_value2, '%Y-%m') >= '2009-03'))
ORDER BY node_changed ASC

kimaldis’s picture

So, running the query pulls out my events OK, so I'm getting the items, just not seeing them. Onwards and upwards.

kimaldis’s picture

I remove my stupid hat and it all becomes clear. The fields list needs to include my event date. As was previously mentioned. Doh!

Took out the update field too, it was cluttering the view.

sorry for the noise.

John Gentilin’s picture

I want to create a view that includes all my events for the current Year..
So in MySQL speak, it would be date between

date_format(date_sub(now(), interval 1 year),'%Y-12-31')
and
date_format(date_add(now(), interval 1 year),'%Y-1-1')

I tried to just enter that and I got something like now - 1 year to now + 1 year

Is there some kind of Drupal date markup, that I can specify ?

It would be nice to have a way to specify "custom function" for the
from and end dates so I can plug in a platform specific date function to
get field > function and field < function..

-John G

gurustump’s picture

I'm no drupal or PHP expert, but I think in my efforts to resolve my own problems with calendar views, I may know the answer to yours.

If you go into "Edit" in your calendar view (/admin/build/views/edit/calendar), you can choose to create a new display of whatever type you desire (block, page, etc). Once you have it, I believe you can click on the only item under "Arguments" (assuming you haven't messed with your defaults) which should be "Date: Date Node: Updated date." When the edit form appears below the main views interface, make sure to click the "Override" button so that you don't mess up the rest of your displays in the view.

Now, your "Action to take if argument is not present" should be set to "Provide default argument." Your "Default argument type" should be "Current date." Scroll down to the "Granularity" section. The default argument it going to get used, and it's going to specify the current date. You can adjust the current date to be the CURRENT YEAR simply by setting the granularity for the date to "Year" (it's on month by default).

That argument should gather all your events for the current year. You can set the rest of the configurable items for your view to tweak it (like using filters to further reduce the number of content items that display in your view). The argument with current date and granularity of year will, in any case, start you off will all the items with a CCK date field in them in that has them scheduled in the current year.

Hope that works for you. :)

PS: if you happen to know of anyone whose "Upcoming" display isn't working because the ">= now" filter is being omitted by the query, I'd love to talk to them.

John Gentilin’s picture

I tried this before and I would of sworn it did not work... This time I had
to save the view before the preview created the correct query.... but it
works fine...

Thank You..

DolbyNR’s picture

Hi all,

After reading many threads, experimenting with it for several nights, asking many people, ... I still can't manage to get upcoming events to function.
It should filter events by city (every city-page should only display their own events).

I explained everything in a seperate thread : http://drupal.org/node/440728

If someone could get me a helping hand ...

desperately yours,
DolbyNR

yesterday’s picture

I'm having a similar problem with creating my Upcoming display as well. Following your advice here, I added the Year-granular argument and passed it the default argument of "Current date", which results in the query selecting all nodes with their CCK Date field value living within the year 2009. I also have a Filter set up to only select nodes with the same field set to a time >= now. This filter does not appear in the query at all. Here's the query that views executes:

SELECT node.nid AS nid,
   node.title AS node_title,
   node_data_field_when.field_when_value AS node_data_field_when_field_when_value,
   node_data_field_when.field_when_value2 AS node_data_field_when_field_when_value2,
   node_data_field_when.field_when_rrule AS node_data_field_when_field_when_rrule,
   node_data_field_when.delta AS node_data_field_when_delta,
   node.type AS node_type,
   node.vid AS node_vid,
   node.changed AS node_changed
 FROM node node 
 LEFT JOIN content_field_when node_data_field_when ON node.vid = node_data_field_when.vid
 WHERE ((node.status <> 0) AND (node.type in ('event', 'seminar')))
    AND ((DATE_FORMAT(ADDTIME(node_data_field_when.field_when_value, SEC_TO_TIME(-18000)), '%Y') <= '2009' AND DATE_FORMAT(ADDTIME(node_data_field_when.field_when_value2, SEC_TO_TIME(-18000)), '%Y') >= '2009'))
   ORDER BY node_changed ASC

My filters look like this in the Views interface:

Date: Date Content: When (field_when) - From date >= now
Node: Published Yes
Node: Type in Event, Seminar

The Date filter is not even making it into the query.

Also, how will your solution for the Year-granular argument behave as the current time nears a year boundary? It looks to me like on Dec 25th, you won't see the Upcoming events for the next year b/c the query defaults to only things within the current year.

kding’s picture

subsribing

eff_shaped’s picture

Useful how-to. It would be great to see it in the handbook.

That way it can be kept up to date with module releases...

I'm working my way through the book: Using Drupal (O'Reilly) by the Lullabot people. (Chapter 9 includes a hands-on for making an events calendar.)

I've found that since publishing, some instructions in the book are outdated, due to recent module releases.

drueditor’s picture

Thanks for the detailed tutorial on implementing an events calendar. I followed the instructions and got a working calendar in short time. However, when I clicked on the 'View Calendar Page' link, my events calendar was displayed fine, but along with this warning message. Do I need to make the changes given below?

• warning: date_timezone_set() expects parameter 1 to be DateTime, null given in
... /sites/all/modules/calendar/includes/calendar.inc on line 414.
• warning: date_format() expects parameter 1 to be DateTime, null given in ... /sites/all/modules/calendar/includes/calendar.inc on line 416.

stovesrhot’s picture

I'm getting the exact same warnings, plus when I go to Year view, I get this error:

Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 25312381 bytes) in /home/user/site/includes/common.inc on line 1571

Could this be some conflict within the most recent Drupal update? Seems odd that we're the first 2 users to experience this problem, and within days of eachother. I just started playing with Drupal so I don't know enough yet to dig into the code and try to figure this one out.

WorldFallz’s picture

See:

Documentation -> Troubleshooting FAQ -> Error Messages -> Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)...

mikew_is’s picture

I am receiving similar problems
# warning: date_timezone_set() expects parameter 1 to be DateTime, null given in /home/drupal-6.13/modules/calendar/includes/calendar.inc on line 414.
# warning: date_format() expects parameter 1 to be DateTime, null given in /home/drupal-6.13/modules/calendar/includes/calendar.inc on line 416

Also on drupal-6.13.

WorlFallz, I am pretty new to drupal, can you explain where I should find the above link

WorldFallz’s picture

That's a completely different error message. I usually search with a unique segment of the error message. For example:

http://drupal.org/search/apachesolr_search/date_timezone_set%28%29%20exp...

The first link in the results seems to describe the problem you are experiencing.

mikew_is’s picture

this was the link I used previously to fix the problem I was having. I did it and it fixed the problem for the admin + authenticated, but not for anonymous.
When I asked I was reffering to the message above
Documentation -> Troubleshooting FAQ -> Error Messages -> Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)...
thanks again for the quick responses

WorldFallz’s picture

Ah ok-- just follow the breadcrumbs-- the first link refers to the "documentation" tab at the top of this page. ;-)

stovesrhot’s picture

OK found a fix for the date_timezone_set() error in this thread:
http://drupal.org/node/463052
I followed the example in post #6 and got the error to disappear.

mikew_is’s picture

Thanks, that worked great!!!
hmm, well i thought it did, but if i logout and view the page as anonymous, it is still there, is there something I need to enable under user privileges ?

stovesrhot’s picture

Yup, you just need to go into user permissions and under "content_permissions module" make sure "view field_event_datetime" is checked for anonymous users.

mikew_is’s picture

thanks very much -- all working!!

polengrace’s picture

also worked for me

rokat’s picture

Thank you for that module it makes my life wonderful.
Is there a way to change the color on the Bloc View entry?
Thanks in advance

darkspaceus’s picture

Everything is working great from what you posted, except that it won't allow me to select a date/time for the event. It just automatically defaults to the date/time I posted it at. I'm probably missing something really minor, but any help pointing me in the right direction would be appreciated.

Anonymous’s picture

...that the View needed to have the correct Argument set [ Date: date (node) ] - not the 'date posted' but the datetime field that I had used for the event.

In the end I made this the default argument for all views instead of per view (ie page, block etc).

H.T.H.

eloya’s picture

Try as I can, once I hit step 3 I get the following message:

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.

I can't figure out what is going on (Drupal 6.13).

khaled30’s picture


SELECT node.nid AS nid,
   node.title AS node_title,
   node_data_field_eventdate.field_eventdate_value AS node_data_field_eventdate_field_eventdate_value,
   node_data_field_eventdate.field_eventdate_value2 AS node_data_field_eventdate_field_eventdate_value2,
   node.type AS node_type,
   node.vid AS node_vid
 FROM node node 
 LEFT JOIN content_type_event node_data_field_eventdate ON node.vid = node_data_field_eventdate.vid
 WHERE ((node.status <> 0) AND (node.type in ('event')))
    AND ((DATE_FORMAT(ADDTIME(STR_TO_DATE(node_data_field_eventdate.field_eventdate_value, '%Y-%m-%dT%T'), SEC_TO_TIME(-18000)), '%Y-%m') <= '2009-09' AND DATE_FORMAT(ADDTIME(STR_TO_DATE(node_data_field_eventdate.field_eventdate_value2, '%Y-%m-%dT%T'), SEC_TO_TIME(-18000)), '%Y-%m') >= '2009-09'))
   ORDER BY node_data_field_eventdate_field_eventdate_value ASC

hujia’s picture

Hello,

I need your help with the titles of the events as they are displayed as the result after clicking and selecting a date (date, or month, year ...) on the block calendar (I used "Style: Unformatted" and the events are shown in rows).

In the Views > Field for my Calendar instance, I chose "Output this field as a link" so that it becomes a link with a dynamic link I retrieve from db. That is good. But Now, I need to make this link for the title lead to and land on an external website page, therefore I need to use target="_blank" to simply open a new window when this title link is clicked. But in Views > Calendar > Field > Title configuration list, there seems to have no option for configuring the target attribute of the title... I then got stuck here.

I search for the possible place I can modify the Calendar or Views' module setting to make this happen: to set this to _blank instead of _self.

Please help me with this... thanks, H.J.

scottrouse’s picture

I've spent a while searching and have been unable to find an answer to these questions:

  1. How do I specify the default view of the main calendar page? In other words, when I go to site/calendar, I was initially seeing the month view. For some reason, I now see the day view. I would like users to see the month view, by default, when they go to the /calendar page.
  2. On the Month view, is there a way to hide the week numbers running down the left side of the calendar.

Thankful for any help or links in the right direction.

Thanks,
Scott

scottrouse’s picture

For number 1 above, it turns out that I'd inadvertently changed the default argument date granularity to Date instead of Month. Switched it back and that solved the issue.

Still looking for an answer to number 2: On the Month view, is there a way to hide the week numbers running down the left side of the calendar?

Thanks,
Scott

AdamHK-2’s picture

2. On the Month view, is there a way to hide the week numbers running down the left side of the calendar.

Go to Month View, click on the gear next to Style: Calendar under Basic Settings. Scroll down to Show Week Numbers and select No.

Update and Save.

apastuszak’s picture

This tutorial worked great for setting up events. Most of the events I have are all day events, mixed with some events that happen at fixed times. How do I create a calendar that does both of those?

irozner’s picture

my view works, but i want to present the time only? can this be done from the view screen?

mskrbic2’s picture

Hello,

All of a sudden the next month link won't work. It just displays the same month. Any ideas?

Mavros Gatos’s picture

I get an error message after I change the Argument: "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."

pattyb-1’s picture

I also followed all the steps outlined above and after I change the Argument, I also get this error in red: "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."

It is as if the calendar view won't recognize my event datetime field as a date field. I tried changing the field associated with the event content type to date (instead of datetime) and editing the View again, but it didn't help.

I am at a loss for what to do. Any assistance would be greatly appreciated.

-Patty

dbeall’s picture

I thought it would be good to change to calendar and get away from the event module..
The arguments in views is the problem here too. Same old story.
The default argument shows node creation date, but we need the event start date as the argument.
I thought after a year and a half with views this might be a little easier.. oh well..
*subscribing too.
It might be good for someone to post their exported code from a working view so the old newbs like me can see how it's done.

BOFH_UK’s picture

Okay, I THINK I've cracked this one at least it seems to have worked for me.

Follow the original instructions all the way through, you'll end up with the "date argument date fields" message. On the Edit view calendar page you should see the 'Fields' section with two entries in it (Node: Title and Node: Update or something like that). Remove both of those entries by clicking each one in turn and selecting Remove from the bottom of the form.

Now you'll need to add two new fields. Firstly add 'Node: Title' back in and select 'Link this field to its node' while you're about it. 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.

One other thing, when I did this the first time I got a SQL dump instead of a calendar. Turns out it doesn't like it if you change the input mask of your date variable from the default 2010-01-05 one. Still working on that, will update if I solve it.

Hope that helps someone,
Steve

scrowder’s picture

Yay! Your clarification about linking to its node fixed it for me
Cheers

not_Dries_Buytaert’s picture

Great! Thx, this worked for me. Running:
drupal-6.19
date-6.x-2.6
calendar-6.x-2.2

dbeall’s picture

The date browser view seems to work for upcoming events.
There is a screen cast for setting this up at
http://www.drupaltherapy.com/node/76
Date + Calendar Screencast

It doesn't have all the different page views that the calendar view has, but it works.
Still working on it.. will report back with any updates..

jaochoo’s picture

Can someone help me how to display upcoming birthdays? The calendar does not display, of course, because it takes the date including the year as an argument which in case of birthdays is some years in the past. Can I manipulate it somehow so that for birthdays it discards the year value but only consideres the day and month? Or replacing the year value of the date field with the current year?

drupix’s picture

Oh yeah ! More than one year later still working !

Good job, thanks

Anticosti’s picture

Subscribing

gscerb’s picture

On the calendar page I have a month view. Is it possible to add a month and year select list filter to navigate quickly to a specified month and year without having to click "next" repeatedly?

dpatte’s picture

I have set up a block view that uses the Argument Date(node) option and it works find when I plug in an ISO date value such as '2010-04' or '2010-W14' into what to use when the argument is not provided. It filters items to dates within that month, or week, or whatever.

So far so good.

But I intend to use this block in the sidebar of a calendar page (mysite.com/calendar/datecode) and to use the date-code argument OF the calendar page as the date code to filter on.

I figure I need some php code that can get at the date-code used for the calendar page itself (which normally appears at the end of the calendar page URL) - something like 'get date-code from URL'.

Also in the case of the default calendar page, i need access to its datecode even though its not in the URL.

Any ideas where i can get the current calendar's datecode from?

dmleforce’s picture

I thought cloning the default calendar view was the same thing as duplicating it. Yet I still have only one calendar view. Can I restore it to its original defaults? Or would I have to uninstall & reinstall the calendar module to get the defaults?

Because I'm trying to figure out how to get rid of the extra column before the first day of the week. I think the dates in it (18, 19, 20, 21, 22, 23) are from the previous month. But I can't figure out how to get rid of that little column. I thought deleting the week view would do it but all I did was delete the week view. This lil column's still there. And I didn't mind having the week view & I think the only way to get it back is restore it (hopefully).

Also...does anybody know what that lil tiny mini calendar under the right hand side is for? If I hold mouse over it - says "add to calendar". I thought that means "add new event" rather then going up to create content & such. But when I click on it - it gives me the opportunity to download a file called calendar.ics.

Finally...how do we change the look of it to match our themes?

Thanks for any help. :)

PB1’s picture

Hi, dmleforce. I have been dealing with several of these issues this week myself, while I am learning the nuances of the Views, Date, and Calendar modules. :)

1. I have not tried cloning any views, so I don't have any answers for that.

2. To get the "Week" attachment view back, I would suggest clicking on the Revert button while you are in the "calendar" view. This will wipe out any changes you have made to the view, but should restore the view back to the default configuration (with the "Week" attachment view in place).

3. The extra column along the left side of the Month calendar page is displaying week numbers. To remove them, click on "Month View", then click on the small gear icon next to "Style: Calendar". In the list of settings displayed below, you will see an option for Show Week Numbers. Set that to "no", and the extra column should disappear.

4. The tiny calendar allows you to export the calendar data in iCalendar format. iCalender is a standard file format for exchanging calendar/event information. See Wikipedia for more details.

5. I have not yet tried to change the look of my calendar to match my site's theme. That is something I will be investigating further soon... ;)

I hope this helps.

Pete

isabelchen’s picture

I had the same problem - the event calendar shows all my nodes with the last updated date, not the event occuring date.

This is because:
The default calendar that comes with the module is set up to display the last updated date of all nodes, which will create an archive calendar. To make it into an event calendar, drop the 'Last updated' field and add in the date field(s) you want in your calendar. Make the same change in the 'Sorts' section of the view. So this means:

Fields:
Node: Title
Content: Event Date and Time (field_event_datetime value)

Sort criteria:
Content: Event Date and Time (field_event_datetime value) asc

The calendar works perfectly after this change, only events showed up with event dates (not the node post/update date)

Hope this helps

esterlin’s picture

Thanks so much for the instructions on how to create an event calendar! I was able to follow all the instructions without trouble.

However, after I created the "Event" content type, in which I added the Event Date and Time field (which has Name: field_event_datetime and Type: Datetime), I tried to create an event and there was nowhere I could input date and time! I still had the fields input format, menu settings, book outline, revision information, URL path settings, comment settings, authoring information, and publishing options. I tried putting the date/time in the "details" of the event, but that did not do anything either. Does anyone have any suggestions? I am using Drupal version 6.x.

Thanks!

esterlin’s picture

Figured it out! For any of you who are having similar issues, you have to make sure you have the permissions to edit field_event_datetime. Go to Admin/User Management/Permissions and down to content_permissions module and click on edit field_event_datetime for your permission.

DrupalDarling’s picture

The "Date Tools" module has a wizard that will do all of this work for us now.

Just install, http://drupal.org/project/date

Then check in your Admin, Content Management section for Date Tools.

then Select "Date Wizard". (It will add all of the Views settings for you)

then go to Admin, Create Content, Date to add entries to your calendar.

easy. :-)

Lythimus’s picture

I found out that you may use a double hyphen (--) without spaces to separate dates to represent a date range as an argument to views for a contentual filter of a date field. It took so long to find this, it was sitting plain as day in the code: YYYY, YYYY-MM, YYYY-MM-DD, YYYY-W99, YYYY-MM-DD--P3M, P90D, etc.

Specifically I'm using the format: YYYY-MM-DD--YYYY-MM-DD.
I wish it was mentioned that modified ISO formats were used.

This is perfect for generating a calendar of some sort manually.

beto_beto’s picture

how can i use views to view latest news before 24 hour or before week ago

how can do it ?!
can anyone help me in this pleas