Upcoming event calendar using date, views and cck

fhsm - October 25, 2008 - 17:16

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

Arguments are the solution!

fhsm - October 25, 2008 - 19:43

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?

How to make a calendar of upcoming events

fhsm - October 25, 2008 - 21:15

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.

wow--- excellent writeup.

WorldFallz - October 25, 2008 - 21:18

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

Multi-Day Events & Timezones

Daniel Berman - October 27, 2008 - 17:06

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?

This was very helpful for

knaa - October 28, 2008 - 15:32

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.

happy coincidence

justageek - October 28, 2008 - 21:20

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.

and another approach without using repeat, when node is same

zilla - October 31, 2008 - 04:46

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

Thanks for this great

elektro - November 20, 2008 - 19:40

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.

Fantastic - thank you!

Sloane DellOrto - October 31, 2008 - 03:58

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. ;-)

Very helpful...but now I'm stuck

bixwilson - October 31, 2008 - 18:14

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.

might be version issues

justageek - November 3, 2008 - 16:36

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.

Just what I needed

danimagoo - November 1, 2008 - 23:18

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!

Advanced Help

kwgossett - November 3, 2008 - 15:32

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

Change date color...

Dr. Rhomboid Go... - November 3, 2008 - 23:28

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

Hi There

richard.e.morton - February 10, 2009 - 22:18

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

Hey all, is anybody here

yoda-fr - November 17, 2008 - 10:57

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!

removing it

kurosevic - November 17, 2008 - 21:24

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?

My Things Show Up Twice

MrBT - November 19, 2008 - 16:18

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?

RSVP?

kurosevic - November 20, 2008 - 02:16

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?

Take a look at the SignUp

adamwebb - November 27, 2008 - 17:13

Take a look at the SignUp module.

Use the RSVP module for

ulf1 - January 9, 2009 - 01:43

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

~
Ulf

Hours of the Day

mediamob - November 20, 2008 - 20:54

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?

Calendar Day View Weirdness

ortizmj12 - November 24, 2008 - 03:19

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! :)

Didn't work for me

atuline - November 27, 2008 - 17:05

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.

Same here

layoric - December 1, 2008 - 21:35

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

Did you make sure to create

ortizmj12 - December 11, 2008 - 03:48

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

Yes, the field was missing.

atuline - December 19, 2008 - 17:28

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.

RE: Yes, the field was missing.

jimmb - April 14, 2009 - 17:06

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

Don't click the '+'

wanderingstan - March 3, 2009 - 22:22

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.

How to make a calendar of upcoming events

brecko - December 1, 2008 - 21:42

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

What does your fields

ortizmj12 - December 11, 2008 - 03:50

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

Awesome!

dennots - December 3, 2008 - 20:55

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

Some Problems for my Calendar

hujia - December 7, 2008 - 02:29

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

Please help with this Calendar of Mine ...

hujia - December 8, 2008 - 04:16

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

Same problem as hujia but slightly different workaround

penteri - January 28, 2009 - 12:51

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

I get to step 3 "Enable the

poobah - December 12, 2008 - 19:26

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.

Did you enable the

ortizmj12 - December 14, 2008 - 02:17

Did you enable the "calendar" module?

same problem with view

deverman - May 2, 2009 - 03:06

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".

Error Message on Step 2

bobwhitleyjr - December 30, 2008 - 16:29

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.

Thanks a ton!

ternto333 - January 7, 2009 - 22:13

You saved my bacon

...

seanmalley - January 27, 2009 - 16:50

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?

Date Tools Wizard

crmanski - March 11, 2009 - 16:12

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"

How to get the month preview on all the pages

gbcomputer - March 17, 2009 - 13:31

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

disregard, I found

gbcomputer - March 17, 2009 - 13:37

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

must add to right block.

How to get the Sunday to First day of Week

gbcomputer - March 17, 2009 - 14:09

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

Thanks saw the

gbcomputer - March 17, 2009 - 14:11

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.

error after adding "sort" criteria

cdragin - October 28, 2008 - 20:19

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.

error after adding "sort" criteria

cdragin - October 28, 2008 - 20:20

oops, sorry for the duplicate entry

dates are off-kilter

Dr. Rhomboid Go... - November 2, 2008 - 00:50

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

Fixed...

Dr. Rhomboid Go... - November 2, 2008 - 14:35

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

example upcoming events block

dugh - November 3, 2008 - 03:00

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

Great example!

justageek - November 3, 2008 - 14:39

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.

off w/ popup dates

Dr. Rhomboid Go... - November 3, 2008 - 23:22

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

@dugh - any interest in walking through those OG tabs!? (offtopi

zilla - November 4, 2008 - 03:14

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

yeah use views and arguments

dugh - November 6, 2008 - 21:13

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.

@dugh

vjordan - November 6, 2008 - 15:15

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.

info

dugh - November 6, 2008 - 21:17

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.

Dugh, can you explain how

jeremy_a - November 6, 2008 - 21:37

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

don't know

dugh - November 9, 2008 - 04:44

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.

I see

vjordan - November 7, 2008 - 11:05

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.

can someone provide a

bjraines - December 31, 2008 - 00:09

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

Thanks for the above

didymo - January 6, 2009 - 21:23

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

broken in latest date/calendar drupal 5 modules

dugh - January 12, 2009 - 17:22

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).

My Filters look like

kwgossett - January 20, 2009 - 03:48

@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?

refresh maybe

dugh - January 25, 2009 - 04:41

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

I have the same issue, that

ulf1 - February 12, 2009 - 21:10

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

I have got the exactly same

Nimo - March 12, 2009 - 15:06

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?

SQL-query replaces now with '2009-01-01' instead for current dat

stephenh - April 7, 2009 - 18:31

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 - April 7, 2009 - 19:21

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. ;-)

You have a really nice and

cloneofsnake - March 3, 2009 - 02:48

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.

weird timezone issue

jewhite - January 8, 2009 - 04:20

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!

Extra Help

fhsm - January 10, 2009 - 23:03

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.

repeating events

beg - February 20, 2009 - 20:46

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

Don't use the date and calendar module

dugh - February 27, 2009 - 15:54

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.

Thanks for this excellent

cloneofsnake - March 10, 2009 - 08:02

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.

subscribe

notebene - March 20, 2009 - 17:10

subscribe

Subscribing

aac - March 21, 2009 - 05:21

Subscribing!!!

problems changing argument to event_datetime

kimaldis - March 23, 2009 - 19:07

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.

OK, the two named fields make

kimaldis - March 24, 2009 - 16:32

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

So, running the query pulls

kimaldis - March 24, 2009 - 16:56

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

I remove my stupid hat and it

kimaldis - March 24, 2009 - 17:08

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.

How to create a Date Range that represents the current Year ?

John Gentilin - March 29, 2009 - 23:51

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

I think this can be done with arguments

gurustump - April 6, 2009 - 08:00

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.

Granularity = year worked

John Gentilin - April 20, 2009 - 17:59

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..

Multiple calendars

DolbyNR - April 24, 2009 - 19:08

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

Similar issue with the Upcoming Display

yesterday - May 4, 2009 - 15:49

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.

subsribing

kding - May 7, 2009 - 12:39

subsribing

bookmarking this thread

eff_shaped - May 12, 2009 - 15:30

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.

Event calendar

drueditor - July 5, 2009 - 11:05

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.

 
 

Drupal is a registered trademark of Dries Buytaert.