[EventCalendar] Repeating events - some thoughts
j at jmeng.de
Sun Apr 15 12:51:15 UTC 2007
here are some thoughts on a possible implementation for repeating events.
The todo-list suggests using a batch-job that adds new events every now and
then. This has two problems:
- How far ahead should events be created? A year? What if a year isn't enough?
What if, for example, a user wants to look up an anniversary in two years?
- Finding/updating instances of a repeating event can be quite tedious.
Another solution is be to generate repeating events on the fly. An example of
how this may be done is http://redalt.com/Resources/Plugins/Countdown,
another WP plugin. This has problems, too: If there are many repeating events
this can be quite a long process.
So what about a combination of the two? Here is a design idea.
- First wp_ec3_schedule should be extended: In addition to the old columns
sched_id, post_id, start, end, allday and rpt we need:
- base_id (the sched_id of the event that is repeated)
- interval (possible values: day, week, month, year)
- skip (integral value, 0 means repeat every <interval>, 1 means
repeat ever other <interval> etc...
- rpt should be boolean, false meaning "this is not a repeating base event",
true meaning "this is a repeating base event".
interval and skip only need to be nonzero in if rpt is true. Otherwise,
they are ignored.
- Naturally if base_id is nonzero the event is an instance of the respective
event. This makes finding all instances of a certain base event quite easy.
- There are several things to consider when generating future repeating
- Time of generation: Must be very regular. Should occur whenever the
plugin is called for the first time after at least a day.
- Updating the base event: Upon generation, base events that are older than
the current date should be converted into normal events (simple thing,
simply set rpt to false and clear interval/skip. Also, the first instance
should become the new base event (i.e. rpt must be set to true, base_id
must be cleared and the interval/skip fields must be copied to the new
base event.) Updating the base event prevents awkward changes to
events that actually have happened. Clearing unused fields should
save some space.
- Number of events generated: This is the tricky part. We need to generate
enough events so that the respective ones show up in our upcoming events
list. I guess it would be acceptable to generate events one year ahead,
but please suggest an improvement.
- When the calendar is navigated to a month outside the pre-generated
timespan, all repeating events should be generated until the end of that
Well, I hope my ideas are clear, but please ask if I failed explaining ;)
Also, please suggest improvements. I'm afraid I'm not really familiar with
Event Calendar's code yet. I only got a small overview of how it works.
The reason I am sending these ideas is that I desperately want Event Calendar
to support repeating events ;) I might participate in coding, although I
don't know how much time I have in the next few months. Anyways, I hope this
helps in some way.
Have fun discussing or flaming :D
More information about the EventCalendar