Jump to content

Calendar: recurring events?


pideluxe
 Share

Recommended Posts

I'm building a site with processwire for a sports club. I want to include a basic event calendar for special events and training hours of the teams. As the training hours are repeating, i need some support for recurring events. This could be very basic, e.g. events every week or every month on a given weekday, no exceptions should be taken in consideration. The events should also be able to be categorized. A list of the next events or a calendar view should be possible to show all events including the recurring ones.

I know, there is Google Calendar loader, but i want the editors to be able to edit all things in PW, not to have edit calendar events somewhere else.

What do you guys think is the best implementation for this setup in PW? Do you have already tried this or made experiences with a similar setup?

Link to comment
Share on other sites

I'm working with a events calendar myself, though I elected to take a more service oriented approach using google calendar and outlook generated *.ics feeds. If your calendar is going to be as simple as you describe, you might be able to get away with the following approach.

  • Set up three datetime fields - event_start, event_end, and recurrence_end.
  • Set up a text field, recurrence_rule (rrule).
  • Add the PHP When library to your project.
  • For recurring events, set your rrule based on byweekday, bymonthday, etc. You can generate rrules with a google calendar (add a recurring event and look at the ical feed) if you're new to them.
  • For the range to be displayed (e.g. today + 3 months) you can use the api to get all events that have start/end OR start/end-recurrence overlap with the displayed range.
  • Set up an array and loop the events, using PHP When to generate a list of occurences if an rrule exists, push rule occurences and non-rrule events in as as siblings, sort by event_start/occurence_start.
  • Render the list of occurences.

That's the basic formula anyways.. If you are avoiding google only because of the look of thier embeded calendars, you might consider rendering your own calendar of events with PHP When and the raw icalendar (*.ics) feed they provide.

Edit: grammar.

  • Like 4
Link to comment
Share on other sites

It's definitely possible to build some great calendars and calendar functions in ProcessWire, and do so without using any other service. But I also want to mention that something like Google Calendar was built with millions of dollars and years of time, so it would be difficult to match the level of capability there. But if your needs are relatively simple, you can probably make a calendar in PW more easily than anywhere. There is no single way to make a recurring event, so I think your approach would just depend on how you've built the rest of the calendar. But I'm imagining that you would do it with a checkbox field called 'recurring', or 'recurring_weekly' or something like that.

  • Like 1
Link to comment
Share on other sites

I was thinking this at one point, but the project was cancelled so I didn't get into implementation part. It had the special need, that the recurring event need to be it's own entity (it might be same event, but different time - but also it might be in different place, have different price etc). How I started to approach the problem was to have "events-item" template which could have children with template "events-instance". Events instances would inherit most of the data from their parent event, but could override some parts of it.

And how I would have implemented is that when saving the "event-item" you could make some selections "Repeat once a week, until <date>" and that would create the required amount of instances as children. Pretty simple actually that way.

  • Like 3
Link to comment
Share on other sites

Thanks guys for your reasonable suggestions. It seems no one has a solution out of the box for this, so i'll have to try it myself. I think I will use a combination of apeisas idea with child pages, incorporating with bens suggestion of using PHP When for generating tbe child pages. I will post the results here when I'm finished.

  • Like 1
Link to comment
Share on other sites

  • 10 months later...

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
 Share

×
×
  • Create New...