5 Days of Mura Plugins: Day 1 - Recurring Calendar Events
Day one of our "5 days of Mura CMS plugins" begins today. I've shifted around the order that we'll be developing them, starting with the as yet unannounced 'nominated' plugin: Recurring Events. It's a pretty straight-forward plugin without needing any extra database tables, so it's a good, simple way to get the week rolling.
Recurring Events was picked because its come up several times over the last year in the Mura Forums, and it should be a good example of how to use Class Extensions and Events to enhance existing functionality.
The plan is to finish at least the base of the plugin each day, so functionality will be fairly limited but should certainly meet all of the base goals. This post will also be updated throughout the day as work progresses, and we'll be tweeting on @meldsoutions as well.
Functionality Overview
Recurring events essentially means that when an event is added in the Site Manager, the exact same event will be repeated on future dates.
I'm going to do this by adding a Page / RecurringEvent Class Extension that will let a content editor pick the frequency of the recurring event (Daily/Weekly/Monthy, for a start) and how often they would like it to recur. The plugin will add a new Page for every instance the event is supposed to occur upon. That should make it easy to remove a specific date if it is canceled or an exception.
It should also be fairly easy to synchronize the pages by adding a Class Extension of 'relatedID' that the original event and all of the subsequent events would have in common. That way when one version was edited, all related pages would be updated as well (it is a 'recurring' event, after all, which means it technically is one event on multiple dates).
Okay, time to get coding!
[update: 10:20 AM 07/02/2011]
This is going faster than expected. I've stripped down our 'base' plugin to the bare minimum. It's a FW/1-based application, in this case mostly just to add some structure. There aren't any display objects, and no real need for an administrator, so everything except a single Event Handler has been removed. The new Class Extension "Recurring Event" has been created, so now I'll be working with the onAfterPageRecurringEventSave event so that when a Page of type RecurringEvent is saved, I can look at the class extension settings and 'recur' the event.
[update: 11:17 AM 07/02/2011]
I've added a new "Synchronize" option so that you can co-ordinate updates across related events. You can pull a single page out of the synchronize now by setting this to 'false'. This means that edits are a) not copied from the related pages into this page, and that b) edits to this page won't be copied to the others. If you want to re-establish synchronization.
One side benefit to doing this via Events is that using the version history to roll back the page to a previous event will trigger the synchronization across all of the related pages as well.
One other note: when creating pages within a content 'save' event, you must set a flag in the global event that prevents those pages from triggering the same event on their own. In other words, I don't want the 'recurring' pages again recurring themselves into infinity!
[update: 12:21 PM 07/02/2011]
Well, it actually looks almost complete. The plugin now adds the following functionality to Mura:
- you can now add a 'Page / Recurring Event' to a Mura calendar, say recur 'Daily/Weekly/Monthly' 'X' number of times, and enable/disable synchronization
- the plugin creates 'X' duplicate pages of the recurring event with new start/end dates
- editing any one of the related pages will automatically copy the changes to the other events
- pulling a page out of synchronization means it can be updated without affecting the other related events, or being change by edits to those other pages
That really has met all of our initial requirements so I'll do a bit of clean-up, add an introduction, and post it for download. It should be available in the next hour or so, barring any bug/issue discoveries.
[update: 12:51 PM 07/02/2011]
Attached below is the 'beta' version of Recurring Events. Let us know via the support forums if you find any issues or bugs.
Tomorrow: Threaded Comments
Tomorrow we will be creating the Threaded Comments plugin (a much-expanded version of our initial 'Subscribe to Page' plan). There is a lot (a lot!) you can do with comments, so depending upon the time we will be adding the following functionality:
- Comments nested by 'reply to'
- Inline comment editor (i.e. appears below what you are replying to)
- Subscribe to a page without actually commenting
- Comment browser in administrator (filters/sorting/paging)
- Render Events for comment block, user/avatar, comment form
- Templated so easily styled
- OnCommentSave/Reply events for adding custom badness-checking
» download Recurring Events plugin (v 0.1b, last update Feb. 07/10)
Comments
- Sean Schroeder
-
Grant, what if the content type os something else, like a link to an external resource?
- February 7, 2011, 3:52 PM
- Grant
-
@Sean, I never considered links when building it.
I've updated to the plugin to support links as well.
- February 7, 2011, 4:57 PM
- Sean Schroeder
-
Sweet! In that case, you may want consider extending it files as well, there are use cases for files too. ; )
- February 7, 2011, 5:03 PM
- Grant
-
@Malcolm: thanks for identifying the admin bug, now fixed.
@Sean, I'll have to ponder the File thing a bit; it's either really simple or really complicated (i.e. do you need to replicate the file as well).
- February 8, 2011, 12:26 AM
- Mark
-
Thanks for working on this. When I try to deploy the plug-in, I am getting a "Login failed for user 'admin'. Is there something I am doing wrong, or is this the admin bug you mentioned to @malcolm above? Thanks!
- February 8, 2011, 12:39 PM
- Grant
-
@Mark ... that doesn't sound like an issue with the plugin, or at least certainly isn't something I've seen before. Are you a Super Administrator on the site?
- February 8, 2011, 12:57 PM
- Patrick
-
How would you go about adding Biweekly to the recurring events calendar. This would be very useful for us since we have a payroll calendar.
- April 14, 2011, 11:43 AM