Jump to content

Recurme – Processwire Recurring Dates Field & Custom Calendar Module.


joshuag

Recommended Posts

  • 2 weeks later...
On 19.12.2017 at 11:33 AM, snck said:

I could not find a way to get the value of the "all day" checkbox and found out that its state is hard-coded (checked) in InputfieldRecurme.module. I need to differentiate between "all day" and "normal" events and output them differently on a clients website. Could you please implement something like a $event->allDay property?

Thanks!

Hey @joshuag, thanks for the update! The toggle fix did not solve my problem (quoted above) because you still do not store the value of the checkbox/toggle. Could you please implement something like an $event->allDay property with a simple binary value? 

Thank you in advance!

Link to comment
Share on other sites

On March 12, 2018 at 10:49 AM, snck said:

Hey @joshuag, thanks for the update! The toggle fix did not solve my problem (quoted above) because you still do not store the value of the checkbox/toggle. Could you please implement something like an $event->allDay property with a simple binary value? 

Thank you in advance!

$event->allDay should be giving you the value of $allDay in the event object true/false. This is also implemented in the json stored in the field. 

Link to comment
Share on other sites

Fresh install of PW 3.0.62, I'm getting this error when installing the latest version of Recurme:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/sites/t/X/public_html/wire/core/Modules.php on line 3921

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

Never seen this before and I'm a bit stumped... Any ideas?

Edit: Increased memory limit with ini_set on the module to see where this goes and got a 30s execution time error. Can't figure this one out, there must be a loop somewhere as increasing that came back to a 800MB memory limit!

Edit 2: Solved! I'll send you an e-mail with details.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

On March 14, 2018 at 2:10 PM, DonPachi said:

Fresh install of PW 3.0.62, I'm getting this error when installing the latest version of Recurme:


Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in /var/sites/t/X/public_html/wire/core/Modules.php on line 3921

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 262144 bytes) in Unknown on line 0

Never seen this before and I'm a bit stumped... Any ideas?

Edit: Increased memory limit with ini_set on the module to see where this goes and got a 30s execution time error. Can't figure this one out, there must be a loop somewhere as increasing that came back to a 800MB memory limit!

Edit 2: Solved! I'll send you an e-mail with details.

I would love to know what happened. Let me know, if I need to, I will issue an update right away. Thank you!

  • Like 1
Link to comment
Share on other sites

Hey @joshuag - not sure if I am just missing it, but is there a method for adding new dates via the API? I have a LOT of events to import. Or, do I have to manually build up the JSON eg:

{"startDate":1518778800,"endDate":1518940740,"allDay":false,"timeEnd":"12:00 pm","dates":["W7/16/Fri/Feb/2018","W7/17/Sat/Feb/2018"],"excluded":[],"active":true,"showResults":true,"rrule":"WKST=MO;FREQ=DAILY;DTSTART=20180216T030000Z;INTERVAL=1;UNTIL=20180217T235900Z"}

and populate with $page->event->date = $jsonStr;

Thanks!

  • Like 1
Link to comment
Share on other sites

1 hour ago, adrian said:

Hey @joshuag - not sure if I am just missing it, but is there a method for adding new dates via the API? I have a LOT of events to import. Or, do I have to manually build up the JSON eg:


{"startDate":1518778800,"endDate":1518940740,"allDay":false,"timeEnd":"12:00 pm","dates":["W7/16/Fri/Feb/2018","W7/17/Sat/Feb/2018"],"excluded":[],"active":true,"showResults":true,"rrule":"WKST=MO;FREQ=DAILY;DTSTART=20180216T030000Z;INTERVAL=1;UNTIL=20180217T235900Z"}

and populate with $page->event->date = $jsonStr;

Thanks!

I don’t have a method to add dates via the api, but that is a good idea.

If you do add dates by populating the json manually, I could see some complications arising depending on how you have chosen the repeat pattern in the Recurme Field. Because the dates are generated based on the rrule via JavaScript. 

I will give this some thought and see how we could make this a no-brainer. 

Thanks for the great idea. 

  • Like 1
Link to comment
Share on other sites

Just now, joshuag said:

I will give this some thought and see how we could make this a no-brainer. 

Thanks for looking into this - right now I am going to have to either build up the JSON, or wait for you to implement an API method. I think the API method is essential because I am sure others will also need to import dates from existing sites. 

I'd appreciate knowing whether you might have time to implement this relatively quickly, or if you think it might take some time to get to - not pressuring, just needing to know if I need to take the JSON approach to meet my deadlines. Thanks for your time!

  • Like 1
Link to comment
Share on other sites

1 hour ago, adrian said:

Thanks for looking into this - right now I am going to have to either build up the JSON, or wait for you to implement an API method. I think the API method is essential because I am sure others will also need to import dates from existing sites. 

I'd appreciate knowing whether you might have time to implement this relatively quickly, or if you think it might take some time to get to - not pressuring, just needing to know if I need to take the JSON approach to meet my deadlines. Thanks for your time!

Sending you a pm. 

  • Like 1
Link to comment
Share on other sites

On 13.3.2018 at 7:42 PM, joshuag said:

$event->allDay should be giving you the value of $allDay in the event object true/false. This is also implemented in the json stored in the field. 

Thanks, it worked for events I received through $recurme->find.

I could not find a way to access the allDay value from an event page.

$allDay = $recurme->event($page->id)->allDay;

Could you please point me in the right direction on how to access the allDay property for one single event?

Thank you!

Link to comment
Share on other sites

  • 2 weeks later...

Hey @joshuag - I am quite confused about calling dates via the API.

From the docs it looks like I should do:

$recurme->event($page)->start_date;

but what if I have more than one recurme field on the page?

I am tempted to parse it myself like this:

json_decode($page->event_dates)->startDate;

because this way I can get the start date from my selected "event_dates" field.

However I am sure I am missing something in how this is meant to be used :)

Any tips please?

Link to comment
Share on other sites

@joshuag - I am also confused about the output of endDate - it's always a day after the specified end date - is this for some reason intentional? It seems confusing to me.

Note that importing using the script you PM'd me is also problematic with this "bug" - if you provide an end date, the end date shown in the field edit dialog is one day before the end, but when you output it via the API it returns the end date I specified on import, so it's quite confusing to the editor.

 

Link to comment
Share on other sites

Ok, more details:If I import a date, the json initially looks like this:

{"startDate":1520956800,"endDate":1522440000,"allDay":false,"timeEnd":"02:00 pm","dates":["W11/13/Tue/Mar/2018","W11/14/Wed/Mar/2018","W11/15/Thu/Mar/2018","W11/16/Fri/Mar/2018","W11/17/Sat/Mar/2018","W11/18/Sun/Mar/2018","W12/19/Mon/Mar/2018","W12/20/Tue/Mar/2018","W12/21/Wed/Mar/2018","W12/22/Thu/Mar/2018","W12/23/Fri/Mar/2018","W12/24/Sat/Mar/2018","W12/25/Sun/Mar/2018","W13/26/Mon/Mar/2018","W13/27/Tue/Mar/2018","W13/28/Wed/Mar/2018","W13/29/Thu/Mar/2018","W13/30/Fri/Mar/2018"],"excluded":[],"active":true,"showResults":false,"rrule":"WKST=MO;FREQ=DAILY;DTSTART=20180313T100000Z;INTERVAL=1;UNTIL=20180330T140000Z"}

Then if I open the page in the admin and save the page (without changing anything), it then looks like this:

{"startDate":1520960400,"endDate":1522479540,"allDay":false,"timeEnd":"02:00 pm","dates":["W11/13/Tue/Mar/2018","W11/14/Wed/Mar/2018","W11/15/Thu/Mar/2018","W11/16/Fri/Mar/2018","W11/17/Sat/Mar/2018","W11/18/Sun/Mar/2018","W12/19/Mon/Mar/2018","W12/20/Tue/Mar/2018","W12/21/Wed/Mar/2018","W12/22/Thu/Mar/2018","W12/23/Fri/Mar/2018","W12/24/Sat/Mar/2018","W12/25/Sun/Mar/2018","W13/26/Mon/Mar/2018","W13/27/Tue/Mar/2018","W13/28/Wed/Mar/2018","W13/29/Thu/Mar/2018"],"excluded":[],"active":true,"showResults":false,"rrule":"WKST=MO;FREQ=DAILY;DTSTART=20180313T100000Z;INTERVAL=1;UNTIL=20180330T140000Z"}

Notice the change in the startDate and endDate stamps as well as the fact that "W13/30/Fri/Mar/2018" is removed after saving.

Help :)

Link to comment
Share on other sites

Sorry, me again :)

When I create a new event through the admin and it's a non-recurring event, it doesn't store the enddate:

{"startDate":1522971420,"endDate":false,"allDay":false,"timeEnd":"08:00 pm"

But you have no API method for getting the end time directly in your API calls (at least not that I can see) - what am I missing?

Link to comment
Share on other sites

18 hours ago, adrian said:

Hey @joshuag - I am quite confused about calling dates via the API.

From the docs it looks like I should do:


$recurme->event($page)->start_date;

but what if I have more than one recurme field on the page?

I am tempted to parse it myself like this:


json_decode($page->event_dates)->startDate;

because this way I can get the start date from my selected "event_dates" field.

However I am sure I am missing something in how this is meant to be used :)

Any tips please?

I am not sure that multiple recurme fields in a single page would work as expected. Parsing the Json would work well. 

Link to comment
Share on other sites

14 hours ago, adrian said:

Ok, more details:If I import a date, the json initially looks like this:


{"startDate":1520956800,"endDate":1522440000,"allDay":false,"timeEnd":"02:00 pm","dates":["W11/13/Tue/Mar/2018","W11/14/Wed/Mar/2018","W11/15/Thu/Mar/2018","W11/16/Fri/Mar/2018","W11/17/Sat/Mar/2018","W11/18/Sun/Mar/2018","W12/19/Mon/Mar/2018","W12/20/Tue/Mar/2018","W12/21/Wed/Mar/2018","W12/22/Thu/Mar/2018","W12/23/Fri/Mar/2018","W12/24/Sat/Mar/2018","W12/25/Sun/Mar/2018","W13/26/Mon/Mar/2018","W13/27/Tue/Mar/2018","W13/28/Wed/Mar/2018","W13/29/Thu/Mar/2018","W13/30/Fri/Mar/2018"],"excluded":[],"active":true,"showResults":false,"rrule":"WKST=MO;FREQ=DAILY;DTSTART=20180313T100000Z;INTERVAL=1;UNTIL=20180330T140000Z"}

Then if I open the page in the admin and save the page (without changing anything), it then looks like this:


{"startDate":1520960400,"endDate":1522479540,"allDay":false,"timeEnd":"02:00 pm","dates":["W11/13/Tue/Mar/2018","W11/14/Wed/Mar/2018","W11/15/Thu/Mar/2018","W11/16/Fri/Mar/2018","W11/17/Sat/Mar/2018","W11/18/Sun/Mar/2018","W12/19/Mon/Mar/2018","W12/20/Tue/Mar/2018","W12/21/Wed/Mar/2018","W12/22/Thu/Mar/2018","W12/23/Fri/Mar/2018","W12/24/Sat/Mar/2018","W12/25/Sun/Mar/2018","W13/26/Mon/Mar/2018","W13/27/Tue/Mar/2018","W13/28/Wed/Mar/2018","W13/29/Thu/Mar/2018"],"excluded":[],"active":true,"showResults":false,"rrule":"WKST=MO;FREQ=DAILY;DTSTART=20180313T100000Z;INTERVAL=1;UNTIL=20180330T140000Z"}

Notice the change in the startDate and endDate stamps as well as the fact that "W13/30/Fri/Mar/2018" is removed after saving.

Help :)

endDate will always be startDate -> till END OF THE CURRENT DAY from the interface if you have a timeEnd (11:59 from your example). endDate always represents the UNIX TIMESTAMP of the day/hour/min in seconds of the END TIME of the event. If you want a date for the events to stop if it is repeating, then it refers the the UNTIL value part of the RRULE UNTIL value. The until value tells recurme to expand the repeating dates up to the UNTIL date. I can see how this is confusing. I might rename these variables now that you have brought it to my attention. 
 

Link to comment
Share on other sites

19 minutes ago, joshuag said:

I am not sure that multiple recurme fields in a single page would work as expected. Parsing the Json would work well. 

I doubt it's a common scenario, but I have never seen a PW fieldtype work this way - normally you just call $page->fieldname so it's weird to get used to parsing an entire page to $recurme.

  • Like 1
Link to comment
Share on other sites

Looking at this all again now. I am working with manually created events (so there aren't any complications with API import) and I am still confused.

This is what I set up:

image.thumb.png.193df0834b9bf4c0fcf0eab290681280.png

 

$recurme->renderEvent($page, array('dateFormat' => 'M d, Y @ g:i a'));

results in: Error: Trying to get property of non-object on line: 682 of MarkupRecurme.module

If I do:

image.png.48d9ed3b2ca9ede323d68ad38480a5be.png

you can see that the "time" is off by an hour - probably a timezone issue, but how can I manually output something like:

March 13th - March 30th, 2018
10:00 am - 2:00 pm

This sort of output I am sure is quite common.

The problem is that end_date: 1522562399 is 2018-03-31 11:59 but the event only goes until the 30th. So how do I get the 30th - do I have to parse UNTIL from rrule, or can do take end_date and subtract one day - what is the reliable way to get the actual end date?

Sorry if I am being stupid - I can't believe I am the only person to come across these issues, but I don't think I am missing anything - I think the module just needs more properties with things like actual start date, start time, end date and end time so we can easily output custom formats.

Let me know if you want to spend a little time on a live chat/call about this.

Thanks!

 

  • Like 1
Link to comment
Share on other sites

39 minutes ago, adrian said:

$recurme->renderEvent($page, array('dateFormat' => 'M d, Y @ g:i a'));

results in: Error: Trying to get property of non-object on line: 682 of MarkupRecurme.module

Sorry, I understand my mistake on this. It needs:

image.png.654a491235782a235c9e172d49044b72.png

Although I still don't know why the dateFormat is not being respected in the output.

Link to comment
Share on other sites

Hey @joshuag - firstly I wanted to send some kudos your way - I feel like I've been complaining lots in my last few posts :) I have been playing around with RenderList, RenderEvent, RenderCalendar etc, and the backend Calendar views and they really are awesome - thanks for all the hard work!

I do have a request though - I have been looking at the rrule in the json and wondering if you'd consider adding a helper to parse the rule into plain english. I'd love to be able to output this: 

WKST=MO;FREQ=MONTHLY;DTSTART=20180402T100000Z;INTERVAL=1;BYDAY=TU;BYSETPOS=2;UNTIL=20180428T235900Z

as: 

Every second Tuesday from 10 am to 2 pm from April 2nd, 2018 till April 28th, 2018

Do you have any thoughts on this? Is there already an inbuilt method that I missed that would help with this?

Thanks again!

 

 

Link to comment
Share on other sites

  • 2 weeks later...
On March 28, 2018 at 7:25 AM, snck said:

Thanks, it worked for events I received through $recurme->find.

I could not find a way to access the allDay value from an event page.


$allDay = $recurme->event($page->id)->allDay;

Could you please point me in the right direction on how to access the allDay property for one single event?

Thank you!

Try this updated file: 
I will add this to my next release.

Thank you!

MarkupRecurme.module

  • Thanks 1
Link to comment
Share on other sites

On April 6, 2018 at 5:54 PM, adrian said:

Sorry, I understand my mistake on this. It needs:

image.png.654a491235782a235c9e172d49044b72.png

Although I still don't know why the dateFormat is not being respected in the output.

change the timeFormat option instead,

or

change the xBefore template to use {date} instead of {time}.
 

'xBefore' => '<li class="rm-list-event {original.name}"><span class="rm-event-date">{time}</span> ',

 

On April 6, 2018 at 5:13 PM, adrian said:

Looking at this all again now. I am working with manually created events (so there aren't any complications with API import) and I am still confused.

This is what I set up:

image.thumb.png.193df0834b9bf4c0fcf0eab290681280.png

 


$recurme->renderEvent($page, array('dateFormat' => 'M d, Y @ g:i a'));

results in: Error: Trying to get property of non-object on line: 682 of MarkupRecurme.module

If I do:

image.png.48d9ed3b2ca9ede323d68ad38480a5be.png

you can see that the "time" is off by an hour - probably a timezone issue, but how can I manually output something like:

March 13th - March 30th, 2018
10:00 am - 2:00 pm

This sort of output I am sure is quite common.

The problem is that end_date: 1522562399 is 2018-03-31 11:59 but the event only goes until the 30th. So how do I get the 30th - do I have to parse UNTIL from rrule, or can do take end_date and subtract one day - what is the reliable way to get the actual end date?

Sorry if I am being stupid - I can't believe I am the only person to come across these issues, but I don't think I am missing anything - I think the module just needs more properties with things like actual start date, start time, end date and end time so we can easily output custom formats.

Let me know if you want to spend a little time on a live chat/call about this.

Thanks!

 

yeah, this looks like a timezone issue. I am digging into it. thanks for bringing it up. Subtracting one day won't work or be consistent. 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...