Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Attached patch is needed to make calendar templates work with date_recur. Not yet submitted to calendar.module as this should be abstracted somehow to not have to call into date_recur directly. Posting here for the moment to make the patch available.
Comment | File | Size | Author |
---|---|---|---|
#58 | 2820803-58.patch | 15.63 KB | heshanlk |
#54 | 2820803-54.patch | 15.57 KB | Suresh Prabhu Parkala |
#50 | 2820803-date-recur_calendar-integration-50.patch | 17.84 KB | wangshy |
#50 | interdiff.txt | 1.21 KB | wangshy |
#45 | 2820803-date-recur_calendar-integration-45.patch | 16.84 KB | mrinalini9 |
Issue fork calendar-2820803
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
kporras07 CreditAttribution: kporras07 at Manatí for Kalamuna commentedThe previously attached patch uses an unexisting function in date_recur; I'm adding it with this patch.
Comment #3
OllaanKoodeis CreditAttribution: OllaanKoodeis commentedShould this work with Calendar? In my setup all recurring dates are shown only in the first date's column. I mean for example there's an event with 4 recurring dates on Tuesdays until 3th of Oct. All the 4 dates are printed in the 12th of Sep date column but nothing for next three Tuesdays columns.
Comment #4
lonalore@KJankko Calendar module only has a "dev" version (which contains a lot of bugs) and will change a lot in the future. So, (currently) it would be rather difficult to find a (permanent) solution to make Calendar and DateRecur modules work together without any conflict. But I have a "solution", which is currently working well.
So, I got Calendar and DateRecur modules working together with the following steps:
1, First of all, I applied some patch files for the modules:
Calendar
https://www.drupal.org/node/2901594 (#14) (partially... I changed some CSS styles)
https://www.drupal.org/node/2845257 (#10)
https://www.drupal.org/node/2859127 (#3)
https://www.drupal.org/node/2644232 (#11)
Date Recur Field (repeating dates)
https://www.drupal.org/node/2820803
https://www.drupal.org/node/2902501 (#2)
2, I created my custom @ViewsRow and @ViewsStyle plugins in my custom module
I uploaded them as a Github Gist file. You can find them here:
[CUSTOM_MODULE]/src/Plugin/views/row/DateRecurCalendar.php
[CUSTOM_MODULE/src/Plugin/views/style/DateRecurCalendar.php
3, Create your calendar views and change "Format" style to "Calendar (with Date Recur)" and change "Show" style to "Calendar entities (with Date Recur)"
Furthermore, I had to alter view queries in order to add additional conditions, because Views only adds the following condition for DateRecur fields:
The condition above is used for a "month" Calendar, but it does not cover all events for September 2017, because what about events start before September and will be end in September or October? So, I add additional conditions to the query to support Date ranges too:
Note: Calendar template files ("week" and "day") don't support multi-day, all-day events, the related code is commented out, so I had to play with template files too. So, currently, Calendar module is a disaster... :/
Alternative solution: Use FullCalendar module with the changes you can find in this pull-request.
Comment #5
akalata CreditAttribution: akalata commented@lonalore thanks for posting this!
Is there a reason against adding your row and style plugins to date_recur?
I've added those in with the attached patch (for date_recur), which along with the original patch for calendar has things up and running for me. I'm still testing it out, but haven't needed to add any of the other patches you mentioned.
Comment #6
akalata CreditAttribution: akalata commentedTried to take a shortcut when making #5, didn't work out as I had hoped!
Comment #7
akalata CreditAttribution: akalata commentedComing back a few weeks later and I'm confused by this issue thread, and I knew what was going on at one point!
We have 3 sets of code changes here:
#0 - @Frando's original patch for the calendar module.
#2/#6 - Patches for date_recur to support the patch for calendar module.
#4 - Includes links to date_recur row and style plugins for calendar views. #6 includes these as well.
Since there are good comments and explanations here, and working on code for date_recur, I think that the original patch for calendar should be moved to a new issue that is marked as "Postponed" (or something else to discourage date_recur work there), with a reference to this issue.
=====
Now the reason I found myself back here: Reporting that something with the Calendar integration is broken
when using Monthly rules -- the first date per month is not displaying in the calendar. Ex: Monthly on the first Friday of the month will display nothing on the calendar, but Monthly on the first and second Fridays will display an event on the second Friday only.See below.Comment #8
akalata CreditAttribution: akalata commentedI had thought the issue was with the first event on a monthly view, but it's really the first time any repeating event is set to view via the calendar.
I've tracked it to where
DateRecurRRule->createOccurrences()
is comparing dates to add to the occurrences list.The$start
date is in my site's local timezone:However, the
$occurrence
dates are in a different timezone type and format:When the code compares the two DateTimes to see if $occurrence is after $start, the comparison fails. I don't know the actual mechanics of this object comparison, but calling getTimestamp() on both gives (1512421200 > 1512442800 = FALSE).
The handoff from the calendar display to date_recur processing is in the row style DateRecurCalendar at
$occurrences = $occurrenceHandler->getOccurrencesForDisplay($dateMin, $dateMax, 1);
. Calendar wants to use our time zone, but RRule wants UTC. The workaround is to add the UTC offset to the timestamp and reset the timezone. @lonalore had similar code in their gist a bit later on, so I've just followed that model.The patch included here incorporates this change and generally brings the views row and style plugins up-to-date with their core counterparts (the gist has different code styles and other automated cleanup which makes it harder to diff).
Comment #9
brooke_heaton CreditAttribution: brooke_heaton commentedI'm a bit confused by this whole thread and the patches. Do I understand correctly that 2820803-date-recur_calendar-integration_8.patch will work properly if combined with a custom module? Are we trying to add /src/Plugin/views/row/DateRecurCalendar.php to a contrib module? Should this not go in as a patch rather than a custom module?
Comment #10
brooke_heaton CreditAttribution: brooke_heaton commentedduplicate commentComment #11
SocialNicheGuru CreditAttribution: SocialNicheGuru commentedif the calendar module is not enabled I get a WSOD and this error:
Fatal error: Trait 'Drupal\calendar\CalendarViewsTrait' not found in -drupal-8.4.4/html/modules/contrib/date_recur/src/Plugin/views/row/DateRecurCalendar.php on line 33
it would be nice if it failed gracefully if the calendar module is not installed
Comment #12
firewaller CreditAttribution: firewaller commented@akalata patch #8 does not seem to be working for me on a clean Drupal 8.4.5 install with calendar (8.x-1.x-dev) and date_recur (8.x-1.0-alpha). With or without the patch, the calendar month view seems to do the following:
Comment #13
akalata CreditAttribution: akalata commentedRe #9 and #12: Patch #8 was a work in progress, I would recommend #6 which iirc is what I'm currently using.
Also re #12: The Calendar module also needs to be patched with the unnumbered patch included in the original post of this issue. Based on your comment I am not sure that this patch was applied.
I am working on figuring out what changes need to be made now that #2627512: Datetime Views plugins don't support timezones is in Core 8.5 and the work on #2604546: Timezone handling in Calendar. I have not decided whether I'm chasing an implementation for 8.4 or 8.5 at this point (functionality is needed for an existing client project that has not yet been updated).
Comment #14
akalata CreditAttribution: akalata commentedIn my limited testing, the patch from #2699477-66: Steps towards handling end dates in Calendar 8 (for the calendar module) accomplishes the same result as the un-numbered calendar-date_recur.patch from the OP, without any hardcoding -- yay!
My current, working setup is as follows:
Comment #15
brooke_heaton CreditAttribution: brooke_heaton commentedThanks for the update @akalata. Will review.
Comment #16
dpiMoving to Calendar project.
Date Recur 2.x is stable enough to start developing against.
Patch needs rework, IMO a part of Calendar, not DR.
Comment #17
mmaranao CreditAttribution: mmaranao commentedHi guys,
Trying to make sense of all these, but I still haven't gotten it to work and am getting the following error:
My current setup is as follows:
Drupal core 8.7.1
drupal/date_recur 8.x-2.0-beta4
- patch https://www.drupal.org/files/issues/2019-05-23/2820803-date-recur_calend...
drupal/calendar 8.x-1.x-dev
- patch https://www.drupal.org/files/issues/2018-04-06/calendar-date_range-26994...
- patch https://www.drupal.org/files/issues/2019-01-19/calendar-timezone-2604546...
Attached also is my current calendar view settings:
https://www.drupal.org/files/issues/2019-05-23/Screen%20Shot%202019-05-2...
Any help would be appreciated, thanks!
Comment #18
mmaranao CreditAttribution: mmaranao commentedAfter spending a few more time on this, I was able to figure it out and reworked the patch to make it work for the month calendar view.
Comment #19
Syntapse CreditAttribution: Syntapse commentedSubscribing. Do project maintainers intend to integrate support for recurring dates in calendar? If so is there any idea when? Thanks.
Comment #20
dpiPlease make sure interdiffs are provided when uploading new patches, as this patch is already significant in size.
Comment #21
Jennyu CreditAttribution: Jennyu as a volunteer commentedI patched 2820803-date-recur_calendar-integration-18.patch
Got the following response:
patching file 2820803-date-recur_calendar-integration-18.patch
Hunk #1 FAILED at 19.
1 out of 1 hunk FAILED -- saving rejects to file 2820803-date-recur_calendar-integration-18.patch.rej
Then I checked Calendar module:
I did get two DateRecurCalendar.php files under /src/Plugin/views/row and /src/Plugin/views/style.
But when I tried to change Calendar view Format and Show, I chose "Calendar(with Date Recur)" and "Calendar entities(with Date Recur)", and Clicked "apply" -- Just can't apply.
Comment #22
iwarmbro CreditAttribution: iwarmbro commentedAlso unable to save newly available "Calendar (with Date Recur)" option, but after successfully applying patches.
Comment #23
lobodakyrylo CreditAttribution: lobodakyrylo as a volunteer commentedI applied patch #18 and couldn't set my view up to show recurring dates. But I used another way to do it.
I attached the new patch that works well for me and an explanation of how it works.
Comment #24
sagesolutions CreditAttribution: sagesolutions commented@iwarmbro I had the same issue..
I see the option Calendar (with Date Recur), but I'm unable to save. When i click "Apply", I get an AJAX error
Turns out, I had to apply the #18 patch to the date_recur module, and #19 to the calendar module
Comment #25
lobodakyrylo CreditAttribution: lobodakyrylo as a volunteer commentedMy patch described in #23 comment is not working anymore. I've made a new one.
Comment #26
sagesolutions CreditAttribution: sagesolutions commentedI've updated calendar to the latest, and applied patch #18 to date_recur module, and patch from comment #25 to calendar module. Both patches applied successfully, but the recurring date is no longer shown in the calendar.
I used the same setup at in the https://www.drupal.org/files/issues/2019-10-01/Events%2B%2528Content%252... image from #23
Comment #27
rwilson0429 CreditAttribution: rwilson0429 commented@SageSolutions, I think its your Contextual filters. I was able to get the Calendar module working with Date Recur using patch in #18 in this issue and, patch #20 at https://www.drupal.org/node/2901594. Note: I've not tried the patch in #25. The summary of steps below pertain to the Calendar's month view, however, it worked for the week and day view as well for me.
Modules I used:
Patches I used:
Create Some Content to use in the Calendar View
Add a Date Recur field to a content type. For this example, I will be using an "Event" content type with a date recur field named 'event_date_recur.'
Add some content using the date recur field that you setup.
Create a Calendar View:
Here is what my Calendar month's View looks like:
Here is results of the Calendar month view:
Comment #28
solide-echt CreditAttribution: solide-echt at Solide BV commentedI was able to get this working with Calendar 8.x-1.x-dev and Date Recur stable release 8.x-2.0 without any of the other modules, along the lines of #27. I found it very confusing this patch is against date_recur module, NOT calendar, even though it was addressed in #5.
The plugins installed by the patch are essentially copies of the row and style plugin for Calendar module. If we want to proceed with that IMHO this patch should be judged by the maintainers of Date Recur, not Calendar.
My first priority as maintainer for Calendar is to investigate what it takes to get Date Recur working in the 8.x-2.x branch, since this branch uses default row plugins. I am getting an error but it looks well isolated (the __clone() method doesn't work on date_recur occurances).
Eric
Comment #29
solide-echt CreditAttribution: solide-echt at Solide BV commentedCreated a new issue with patch for 8.x-2.x branch, see #3127308: Support Recurring Dates Field in Calendar 8.x-2.x. Hope to find some time coming week to rework this against 8.x-1.x.
Comment #30
rhiss CreditAttribution: rhiss commentedWhile testing #27, it seems like the view shows the 'event' (rrule) only at the startdate month, no monthly or inter-month recurring dates.
Comment #31
solide-echt CreditAttribution: solide-echt at Solide BV commentedHere's a new patch to integrate date_recur. This patch is against calendar 8.x-1.x-dev, NOT against date_recur!
As for the comment made by rhiss in #30: this is a missing feature in 8.x-1.x branch and not specifically happening with recurring dates. E.g. if you have a datetime_range node which starts before your current calendar it is not shown as well. In the 8.x-2.x branch this is solved by using calendar specific argument plugins.
Comment #32
solide-echt CreditAttribution: solide-echt at Solide BV commentedComment #34
solide-echt CreditAttribution: solide-echt at Solide BV commentedfixed as much of the coding comments as possible.
Comment #35
banoodle CreditAttribution: banoodle at Kanopi Studios commentedExcited to see there is a patch - will try to review tomorrow.
Comment #36
dpishould be injected
should be injected
I dont think you should be looking for provider. You should be able to use instanceof Daterecuritem somehow, in order to capture any field types that extend date_recur
datetime/daterange/date_recur all have a computed datetime object helper. You should be able to do $item[0]->start_date / $item[0]->end_date instead of needing to use \DateTime::createFromFormat in many places.
use of FQN
see above re using computed fields
You should avoid using timestamps in any code because dates may not be after 1970, and its best to not store or manipulate dates in integer form due to variable length/memory issues
Using dateformatter (with timestamp) opens you up to not supporting out of range ints (pre 1970)
Skimmed through for a code review. Not a technical/big picture review.
Comment #37
solide-echt CreditAttribution: solide-echt at Solide BV commentedDaniel,
Thank you for your thorough feedback. I wasn't sure how to handle injection without date_recur becoming a dependent module but found a reference using a stub service that can be included in calendar. This makes the code in row plugin much cleaner, no need for getTypeProvider(). As to 5: I think we can safely assume $calendar_event->recurring by definition is a DateRecurItem or is null; I want to avoid having date_recur in the 'Use" section as this implies a dependency.
Usage of timestamp and dateformatter (with timezone) was part of the 8.x-1.x code all along. Though I fully agree I think we should leave this to the 2.x branch (where DrupalDateTime class is used as much as possible).
Comment #38
dpiThe two mentioned services for DI are from core. There was no dependency on a DR service in my notes above.
Imports may be used even if the class does not exist. For example I can do
$obj instanceof A\Class\That\Doesnt\Exist
. Introducinguse
does not imply a dependency.Looking at the interdiff at 37, I dont understand why you need to depend on any DR services.
Comment #39
Elin Yordanov CreditAttribution: Elin Yordanov commentedRe-rolled the patch #18
Comment #40
heshanlkComment #41
solide-echt CreditAttribution: solide-echt at Solide BV commented@Елин Й. Could you provide an interdiff? Thx.
Eric
Comment #42
Elin Yordanov CreditAttribution: Elin Yordanov commented@solide-echt,
I just added the missing new line at the end of the file. See the interdiff file. And I just realized that this patch is for date_recur module, not for calendar. I got this patch in a project which was not applying because of the missing new line.
Comment #43
sagesolutions CreditAttribution: sagesolutions commentedPatch #37 fails to apply to the calendar module.
Comment #44
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedRerolled patch #37, please review.
Comment #45
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedPlease ignore patch #44, here is the rerolled patch for #37, please review.
Comment #47
mrinalini9 CreditAttribution: mrinalini9 at Srijan | A Material+ Company for Drupal India Association commentedComment #48
solide-echt CreditAttribution: solide-echt at Solide BV commentedPlease don't post patches that apply to the date_recur module in the calendar issues thread. The latest patches should be applied to the calendar module.
Thanks,
Eric
Comment #49
wangshy CreditAttribution: wangshy at Northern Commerce commentedAdd support to argument context from relationship(interdiff.patch), otherwise recurred date over span more than one month can't show up normally (which should use "date_recur" table related to node instead of field from node directly).
Reroll patch for 1.0.0-alpha2 for production version
Comment #50
wangshy CreditAttribution: wangshy at Northern Commerce commentedmistake on #49 patch. #50 is the right one to support relationship and reroll on 1.0alpha2
Comment #51
wangshy CreditAttribution: wangshy at Northern Commerce commentedThe patch is still not perfect yet at it displays only first recur date instead of date of each occurrence. So far workaround is hiding date but leaving time only.
Comment #52
Neslee Canil PintoLatest patch is not applying, can you please reroll
Comment #53
Suresh Prabhu Parkala CreditAttribution: Suresh Prabhu Parkala at Specbee commentedComment #54
Suresh Prabhu Parkala CreditAttribution: Suresh Prabhu Parkala at Specbee commentedRe-rolled patch please review.
Comment #56
dankegel CreditAttribution: dankegel commentedSounds like this is close... can anyone comment on the usability of Calendar on drupal 9, including recurring dates?
Comment #57
heshanlkRe-rolled
Comment #58
heshanlkComment #60
sagesolutions CreditAttribution: sagesolutions commentedI applied the patch #58 along with Recurring Dates Field 8.x-2.2 on Drupal 8.9.13
I also added the #39 patch https://www.drupal.org/files/issues/2020-05-20/2820803-date-recur_calend..., but not sure if this was required.
I ended up using Format: Calendar and Show: Calendar Entities in the calendar month view.
Everything seems to be working properly.
Comment #63
Christopher Riley CreditAttribution: Christopher Riley commentedI would love to check out this functionality however patch 58 doesn't apply and I am confused what was done in 62. Can someone please advise?
Thanks in advance.
Comment #64
Sseto CreditAttribution: Sseto commentedI'm on the same boat as Christopher Riley.
Comment #65
kporras07 CreditAttribution: kporras07 for Kalamuna commentedHi,
Comment #58 was a Merge Request. You can find it by clicking on "merge request !6". You can see the code at https://git.drupalcode.org/project/calendar/-/merge_requests/6 and could downloading as patch at https://git.drupalcode.org/project/calendar/-/merge_requests/6.patch
You could also read more about MRs in Drupal.org at https://www.drupal.org/docs/develop/git/using-git-to-contribute-to-drupa...
Hope this helps (if I understood well your question),
Comment #66
Christopher Riley CreditAttribution: Christopher Riley commentedI am missing the boat somewhere. I applied the needed patches or the ones that seem to still be needed and followed the details in #27 and when I view the current month I see the event (currently the event is every 14 days starting on Sunday April 4th continuing forever), however when I advance to the next month no entries are shown.
Suggestions?
Comment #69
waako CreditAttribution: waako at Annertech commentedPatch from MR !6 worked for me with recurring date as contextual filter on Calendar view.
However, when viewing other calendar view using core
datetime
field, it threwError: Call to undefined method Drupal\datetime\Plugin\Field\FieldType\DateTimeItem::getHelper() in Drupal\calendar\Plugin\views\row\Calendar->explodeValues() (line 592 of modules/contrib/calendar/src/Plugin/views/row/Calendar.php).
It appears that once date_recur module is installed, the check on line 530 (
if ($this->dateRecurService->getOptionalDependency()
) returns true for all field types, but missing the helper used on line 592, hence the error.Added a check that field type is
date_recur
before assigning$event->recurring
Hope that makes sense, and is the correct approach.
New to the MR process, so apologies for the extra branch.
Comment #71
3CWebDev CreditAttribution: 3CWebDev commentedOn Drupal 9:
I've applied the merge request #6 patch along with patch #39 but recurring dates are still not showing up correctly for me. Only the first occurrence of a recurring date is displayed on the calendar and no further dates.
Besides applying the patch(es), are there any config changes or anything else that may need to be done to get recurring dates to display correctly?
It seems like people in the thread have had intermittent success and for those that got it to work was some time ago and most likely older versions of Calendar, Recurring Dates, and Drupal.
Has anyone had success with current versions?
Comment #72
johnvComment #73
johnv