This issue summarizes and provides a solution (or at least a workaround) for a problem I and others have reported. When certain reasonable looking settings are used in Views for repeating events, the resulting set of events show the wrong dates. Instead of each repeat showing the date of that repeat, it shows a set of date based on the events first occurrence (iteration). I believe that this may be the same problem that has also been reported by smurray, robclay, and mwbyrd. The essence of the workaround is that it makes a big difference whether you select Method:OR (bad) or Method:AND (good) to filter upcoming repeating events, even if you are filtering based on a single field, when it seemed to me like the Method would be irrelevant.

I'm using PHP 5, and can provide a export of the field I'm using and the view if that would be useful.

For this explanatory example I'm using the Live Preview function of Views (just for my convenience, and it shows the problem accurately). My repeating events' repeating date field is named "field_datetime_repeating". When the Views listing is correct it looks like this:

Monthly Universal Worship
field_datetime_repeating value: 01/20/2009 7:30pm
Monthly Zikr
field_datetime_repeating value: 01/27/2009 8:30pm
Dances of Universal Peace (Qahira)
field_datetime_repeating value: 02/03/2009 7:30pm
Way of the Heart
field_datetime_repeating value: 02/05/2009 7:00pm
Dances of Universal Peace (Habib)
field_datetime_repeating value: 02/12/2009 7:30pm
Monthly Universal Worship
field_datetime_repeating value: 02/17/2009 7:30pm
Way of the Heart
field_datetime_repeating value: 02/19/2009 7:00pm

These are all monthly events except Way of the Heart which is bimonthly. The filter uses field_datetime_repeating for "now +35 day" and the Views sort is set to use field_datetime_repeating also. I've set the datetime filter such that it shows you two Monthly Universal Worship events, and two Way of the Heart events, each displaying their correct future date for that event. Perfect.

When the Views settings are very slightly altered, even though superficially the change should not make any difference as far as I can understand, we see this:

Monthly Zikr
field_datetime_repeating value: 10/28/2008 8:30pm
Dances of Universal Peace (Qahira)
field_datetime_repeating value: 11/04/2008 7:30pm
Way of the Heart
field_datetime_repeating value: 11/06/2008 7:00pm
Dances of Universal Peace (Habib)
field_datetime_repeating value: 11/13/2008 7:30pm
Monthly Universal Worship
field_datetime_repeating value: 11/18/2008 7:30pm
Way of the Heart
field_datetime_repeating value: 11/20/2008 7:00pm
Monthly Zikr
field_datetime_repeating value: 11/25/2008 8:30pm
Dances of Universal Peace (Qahira)
field_datetime_repeating value: 12/02/2008 7:30pm
Way of the Heart
field_datetime_repeating value: 12/04/2008 7:00pm
Dances of Universal Peace (Habib)
field_datetime_repeating value: 12/11/2008 7:30pm

What you're seeing is a reasonable looking (although wrong) list of upcoming events, but with each showing a date based around the date of the first event in the series (i.e. the "value" of the field_datetime_repeating field without the rrule applied). For instance, the actual first Monthly Zikr event in the series was 10/28/2008, followed by one a month later at 11/25/2008. The list above is showing those two events based on the repeat-rule for the Monthly Zikr event. But remember, I've set the filter to show "now +35 day", which worked fine in the first example, but this time is acting as if the entire series of "upcoming events" should be generated based on some date back in Oct 2008. This is not a list of upcoming events and dates. Bad!

What I've changed is the Settings (the gear icon, Configure Extra Settings) for the filter in Views that screens for only upcoming dates [Event Date:Date Content:Date of first event in series (field_datetime_repeating)]. As before, the only Date Field(s) I have checked in that filter is "Content:Date of first event in series" (i.e. the datetime of the initial iteration of the event). What I've done differently is that I've selected Method:OR instead of Method:AND as in the first case. The latter Method (AND) produces the correct dates for upcoming events, the former (OR) produces the error.

Now since there's only one Date Field(s) checked, it didn't seem to me like it should matter if AND or OR was applied. It does matter. Below the Method section is the explanation "Method of handling multiple date fields in the same query. Return items that have any matching date field (date = field_1 OR field_2), or only those with matches in all selected date fields (date = field_1 AND field_2)." Maybe that explains things perfectly, but my interpretation is that it only explains how the method will handle the situation when more than one box is checked.

So perhaps this is a feature and the Method explanation needs to be expanded, or else this is a bug in the OR method that generates an incorrect set of events and dates. Karen?

And I'll add here that the Date/Calendar modules are totally awesome and thank you Karen for your terrific work! (Just a tiny problem here.)

Eric

Comments

chrishathaway’s picture

Hey Eric,

FIrst of all, thanks for you help on this. I ran into this same problem on my site, and what you've done so far has been very useful. One question, though: in your view, is your "Row Style" set to "Node" or "Fields"? If I have mine set to "Node", it still only displays the first iteration's date.

ericm’s picture

Hi Chris,

For both the block and page views I have my Row Style set to Fields rather than Node (with none set as inline). So when someone generates an upcoming events view they see a list of entries like:

:: Monthly Universal Worship
Date and time: Jan 20 2009 7:30pm America/Toronto
Contact: Amina
Location: Amina's home (please contact her for more info)

A Universal Worship service, honoring the sacred in all religious traditions.

with one of these for every node that the Views filter produces. That date and time are for the correct upcoming event. The fields I've added to the View are Node Title, field_datetime_repeating, field_contact and field_location (two other fields I added by CCK to my "repeating events" nodes), and finally Node Body. Those are the fields stored in the db associated with my repeating event nodes. Incidentally, I got the "::" by making the label for Node Title just ":" because I think the double colon makes the event title easier to find in the list and I haven't employed any custom templating to make each individual node in the listing pop out.

Just for testing your case, I just tried setting my Row Style to Nodes instead of Fields, made sure "Display only teaser" was unchecked, and checked the Views Live Preview for Page. (Node style only makes sense for Page so I'm presuming you are referring to a Page view.) It shows a list of events like this:

Monthly Universal Worship

A Universal Worship service, honoring the sacred in all religious traditions.

Next upcoming date and time:
Jan 20 2009 7:30pm
Location:
Amina's home (please contact her for more info)
Contact:
Amina
Date of first event in series, then repeats (See "Repeats" above):
Nov 18 2008 7:30pm America/Toronto
Repeats every month third Tuesday until Tue Oct 18 2011

That is how my Node display for that event appears outside the Views system, too. I believe that is the same display as you are describing, because my repeated datetime field has the label "Date of first event in series, then repeats," which shows as Nov 18 2008 in the example above (i.e. the first iteration, as you noted).

Note that my "Next upcoming date and time" above is an added Computed Field as described elsewhere, and I am not sure if it's actually computing that date on the fly during View generation, although since I am not storing the Computed Field in the database I suppose it must be (unless its still in the db from my testing and I need to clean it out manually!). None of my other added CCK fields will show up in that Page view (field_datetime_repeating, field_location, field_contact) if I check "Display only teaser" in the Settings for Node style.

Also note that if you choose to hide the field_datetime_repeated field (or whatever you've labeled your own repeating datetime field) then it will also hide the "Repeats" tab in the regular Node display, which may or may not be what you want. I want to keep that tab, so I added the rather long label to my field_datetime_repeated in the hope that users wouldn't confuse the first iteration date with the next upcoming date. I'm not entirely happy with that.

So my conclusion is: yes, if you select Node as the Row Style then you are going to be shown only the date of the first iteration in the repeating event series, rather than the upcoming date generated by the repeat rule. Using Fields style (with the AND method) produces the calculated next upcoming date instead. However, you may be able to still get a next event date in a Node style View if you add a Computed Field to generate it, but I'm not 100% sure if that's generally true even though it seemed to work in my test above.

I hope some of that made sense and was useful!

chrishathaway’s picture

Hey Eric,

Thought I would update you on how this turned out. I ended up just using the Row Style set to Fields and theming them. I tried using your Computed Field, but it would only show the next occurrence of the event. This is fine when you're just looking at the node page, but when there are several events listed in a view, including multiple iterations of an event series, they still show the same date in every iteration, just the next date instead of the first.

Oh, and one other little thing on that Computed Field.... the following line:

$fromdate_text = $node->field_datetime_repeating[0]['value'];

should use the variable instead, like this:

$fromdate_text = $node->{$datetime_repeating}[0]['value'];

Thanks again for your help on this. I think there's still a legitimate bug or two through all of this that should be taken care of in the Date Repeat module.

ceaker’s picture

This sounds very similar to a problem I described here. Difference is that I wasn't having a problem getting the node with a repeating date to display correctly till I tried using the "Group Multiple Values" checkbox in the views date field settings. I only want the next itteration of a repeating date to display in my view. In the above example, I would want my view to look exactly the same but with only one instance of the "Way of the Heart" event.

Has anyone had any success using the "Group Multiple Values" checkbox with repeating date fields? Am I misunderstanding how that checkbox is supposed to be used?

georgedamonkey’s picture

Thank you for all your work on this! It's helped me out a lot. And, I've now got it so when you view an event it shows the date that particular instance of the recurrence happens.

I used the code you posted here: http://drupal.org/node/357867

The only issue I have left is, it shows the correct date for the event, but then for time it shows the current time rather than the event's time. Any idea what may be wrong?

KarenS’s picture

Status: Active » Fixed

This thread has wandered around and I'm not completely sure what the current issues are in -dev (the rc6 version is very out of date now).

I just committed a new feature to -dev that might fix these issues. The formatters now have settings so you can do choose to show or not show the repeat rule, display all repeats or the first repeat or the next repeat from today or whatever. You can also choose if you want to display both the from and to dates, or just the 'From' date or just the 'To' date.

If you use Advanced Help you'll see some popup help for this. The formatter settings are on the Display fields page and when you add Date fields to views.

I'm sure it will still need some tweaking to produce the right results everywhere, but so far in my testing it works to make this all very customizable.

If there are no immediate bugs, I'm planning to roll a new release with this in it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.