joshuag

Recurme – Processwire Recurring Dates Field & Custom Calendar Module.

Recommended Posts

5 minutes ago, adrian said:

Thanks @joshuag - just curious - did you also take a look at the rrule code icon idea I brought up?

I did not modify it. I didn't even think of it, but it's a good idea. I'll do a quick update on that. Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the update @joshuag, great to see Recurme continue being updated. 

I haven't had opportunity to update my current installs yet, but have a new project Recurme would be ideal for.

  • Thanks 1

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
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. 

Share this post


Link to post
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.

  • Thanks 1

Share this post


Link to post
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!

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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.

 

Share this post


Link to post
Share on other sites

Even more confusion. Take these examples - why does the value of enddate vary depending on how I get it?

image.png.74ef1e29bb21d3cac1c7e859afce37f3.png

Share this post


Link to post
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 :)

Share this post


Link to post
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?

Share this post


Link to post
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. 

Share this post


Link to post
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. 
 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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.

Share this post


Link to post
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!

 

 

Share this post


Link to post
Share on other sites

Hi @joshuag - sorry to bump this, but wondering if you've had any thoughts on any of my questions above?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
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

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By OLSA
      Hello for all,
      ConfigurationForm fieldtype module is one my experiment from 2016.
      Main target to build this module was to store multiple setup and configuration values in just 1 field and avoid to use 1 db table to store just single "number of items on page", or another db table to store "layout type" etc. Thanks to JSON formatted storage this module can help you to reduce number of PW native fields in project, save DB space, and reduce number of queries at front-end.
      Install and setup:
      Download (at the bottom ), unzip and install like any other PW module (site/modules/...). Create some filed using this type of field (ConfigurationForm Fieldtype) Go to field setup Input tab and drag some subfields to container area (demo). Set "Name" and other params for subfields Save and place field to templates ("Action tab") How to use it:
      In my case, I use it to store setup and configurations values, but also for contact details, small content blocks... (eg. "widgets").
      Basic usage example:
      ConfigForm fieldtype "setup" has subfields:
      "limit", type select, option values: 5, 10, 15, 20
      "sort", type select, option values: "-date", "date",  "-sort", "sort"
      // get page children (items) $limit = isset($page->setup->limit) ? $page->setup->limit : 10; $sort = isset($page->setup->sort) ? $page->setup->sort : '-sort'; $items = $page->children("limit=$limit, sort=$sort");  
      Screenshots:


       
      Notes:
      Provide option to search inside subfields Provide multilanguage inputs for text and textarea field types Provide option for different field layout per-template basis Do not place/use field type "Button" or "File input" because it won't works. Please read README file for more details and examples Module use JSON format to store values. Text and textarea field types are multilanguage compatible, but please note that main target for this module was to store setup values and small content blocks and save DB space. Search part inside JSON is still a relatively new in MySQL (>=5.77) and that's on you how and for what to use this module.
      Thanks:
      Initial point for this fieldtype was jQuery plugin FormBuiled and thanks to Kevin Chappel for this plugin.
      In field type "link" I use javascript part from @marcostoll module and thanks to him for that part.
      Download:
      FieldtypeConfigForm.zip
      Edit: 14. August 2018. please delete/uninstall previously downloaded zip
      Regards.
         
    • By bernhard
      @Sergio asked about the pdf creation process in the showcase thread about my 360° feedback/survey tool and so I went ahead and set my little pdf helper module to public.
      Description from PW Weekly:
       
      Modules Directory: https://modules.processwire.com/modules/rock-pdf/
      Download & Docs: https://gitlab.com/baumrock/RockPdf
       
      You can combine it easily with RockReplacer: 
      See also a little showcase of the RockPdf module in this thread:
       
    • By bernhard
      WHY?
      This module was built to fill the gap between simple $pages->find() operations and complex SQL queries.
      The problem with $pages->find() is that it loads all pages into memory and that can be a problem when querying multiple thousands of pages. Even $pages->findMany() loads all pages into memory and therefore is a lot slower than regular SQL.
      The problem with SQL on the other hand is, that the queries are quite complex to build. All fields are separate tables, some repeatable fields use multiple rows for their content that belong to only one single page, you always need to check for the page status (which is not necessary on regular find() operations and therefore nobody is used to that).
      In short: It is far too much work to efficiently and easily get an array of data based on PW pages and fields and I need that a lot for my RockGrid module to build all kinds of tabular data.

      Basic Usage

       
      Docs & Download
      https://modules.processwire.com/modules/rock-finder/
      https://gitlab.com/baumrock/RockFinder/tree/master
       
      Changelog
      180810, v1.0.5, basic support for options fields 180528, v1.0.4, add custom select statement option 180516, change sql query method, bump version to 1.0.0 180515, multilang bugfix 180513, beta release <180513, preview/discussion took place here: https://processwire.com/talk/topic/18983-rocksqlfinder-highly-efficient-and-flexible-sql-finder-module/
    • By Thomas Diroll
      Hi guys I'm relatively new to PW and just finished developing a page for a client. I was able to include all necessary functionality using the core fieldtypes but now I it seems that I need to extend them with a custom one. What I need is a simple button, that copies the absolute url (frontend not PW-backend) of the page which is currently edited to the clipboard. As this feature is only needed inside a specific template, I tend to use a custom fieldtype which provides this feature. I've been looking inside the core modules code (eg. FieldtypeCheckbox.module) but I don't really get the structure of it and how its rendered to the admin page. I also didn't find a lot of tutorials covering custom fieldtypes.
      Maybe some of you could give me some tips on how to write a basic custom fieldtype that renders a button which copies the value of
      page->httpUrl() to the clipboard using JS. Thanks!
    • By BrendonKoz
      I began writing this module from scratch, basing it off simple examples of modules, trying to learn the necessary methods required to create a fieldtype. I was WAY off, but learned a lot. Eventually I moved towards examining the FieldtypeEvents example from Ryan and, in many areas, copy/pasting and then adjusting the code (and then trying to determine what it all was doing) method by method, file by file (from his example to my module).
      I've gotten to the point where I was ready to test the code - I haven't fully fleshed out my visual interface, nor integrated any of the 3rd party API tools this will (can) take advantage of. I also haven't implemented any JS or CSS for the interface. Right now I'm just trying to get it to save and then display any of the data that has been entered into the form fields of a template from the admin. When I save the page, the field is reset to defaults and no feedback message (for the field) is shown at the top of the page upon reload. When using Tracy Debugger from within the processInput method (immediately attempting to debug the $input variable), Tracy caught no data to be shown.
      If anyone has some time to take a quick look and see what I might've done wrong I'd be super grateful. I've had no forward progress in about 3 days (and like many others was unable to get Xdebug breakpoints working in PHPStorm). 😞
      https://github.com/BrendonKoz/FieldtypeBooks