(For more resources on Plone, see here.)
The techniques in this article are applicable in many organizational schemes. We present one common arrangement as an example: a top-level folder where visitors can browse the highest-profile events on the site.
Show events on a calendar
Plone’s out-of-the-box Events folder provides a basic way to find events: it displays them in a chronological list broken into pages of 20 each. While fine for simple cases, this is cumbersome for visitors who want to look at events for a certain future date. Part of our goal is to set up a monthly calendar to make this common case easy:
Our first step toward the monthly calendar is to replace Plone’s stock Events folder. Out of the box, it holds individual events along with a summarizing collection that acts as its front page. If you don’t need a drill-down way of browsing your events by subject—for example, if you have so few that they all fit comfortably on a calendar like the above—you can leave the default Events folder in place. Otherwise, follow the instructions below to replace it with a standalone collection; this will interact better with Plone’s navigation portlet, which we will use to implement the drilldown browsing. If you choose to stick with the stock Events folder, you may still wish to adjust the criteria of its inner collection as described in the following:
- First, delete the Events folder.
- Replace it with a new collection called “Events”. Give it an Item Type criterion, and tell it to pull in everything of the type Event.
The original Events collection had a Start Date criterion to keep past events off the page. We won’t need that, since the calendar view we are about to apply keeps past events tucked away implicitly—and we do want the ability to see old events when we navigate to previous months.
The original collection also had a State criterion that limited it to showing published events. If you need only to hide unpublished events from visitors, then you can dispense with this: the internal search routines used by the collection will naturally show only what the current user has permission to see.
Preventing a common contributor error
Often, a less proficient contributor will add an event, see it on his or her own calendar, and move on, neglecting to publish it. Adding the State criterion can serve as a reminder, preventing the event from appearing until properly published. The downside is that it makes the calendar useless for intranets: Events that aren’t publicly visible will never show up. But if you have no non-public events to list, consider recreating the State criterion.
- If you never want to show access-controlled events on the main calendar add a State criterion limiting the collection to published items.
The Events collection is finished. Next, we apply a monthly calendar view to our data.
Meet Plone4Artists Calendar
Plone’s built-in event listings are rather basic. We need to do special tricks with collections and default views just to sort them in chronological order. At best, this is several extra clicks, and, at worst, it can confuse your less technical content contributors. A third-party product called Plone4Artists Calendar makes this easy and gives us several other capabilities to boot.
Plone4Artists Calendar is the current frontrunner in the Plone calendaring space. It provides…
- Daily, weekly, monthly, and a few other calendar-like views for folders and collections
- Rudimentary recurring event support
- Hooks for pulling events from other systems in realtime, with a bit of coding
Don’t let the name “Plone4Artists” put you off if you aren’t an artist; though the Plone4Artists suite of products came out of a project to provide artist community web sites, there’s nothing particularly artist-centric about them. In fact, there has been discussion about renaming them.
The runner up: CalendarX
The other Plone calendar worth considering is CalendarX, whose most recent release at the time of this writing is 0.9.1. 0.9.0 was the first update to the product since since 2005 and represents a major refit. Its ancient data-modeling internals were replaced with a modern Archetypes implementation, and one no longer needed to venture into the ZMI to do simple configuration. Speaking of configuration, CalendarX exposes a lot of it: 6 tabs packed with options for tweaking calendar format, event display, widgets, and more. There are 57 options alone regarding its CSS cosmetics. If you need a specific look and aren’t comfortable writing your own CSS or template code, CalendarX may be the ticket.
However, be warned that CalendarX has a history of being sporadically maintained. It lacked Plone 3 compatibility for a long time, and compatibility work began only when a group of stranded Plone 2.5 users at Pennsylvania State University put a week of development work toward it. Its internals still hold a lot of legacy that may prove difficult to maintain as Plone evolves.
Plone4Artists Calendar, on the other hand, is a simpler product—both inside and outside and with all the good and bad that entails—and the winds of further community effort are blowing in its direction. Its maintainable design and the willingness of developers to work on it make it the solution least likely to leave you stranded; this is why it is our recommendation in this article.
Install Plone4Artists Calendar
Before we can make use of its views, we need to install the product—actually, two products and several supporting packages. Weave these directives into the proper sections of your buildout.cfg…
...other eggs here...
...other ZCML listings here...
# Plone4Artists Calendar doesn't support Plone 3.3's
auto-ZCMLloading as of 2.0a2.
[productdistros]recipe = plone.recipe.distros
…run buildout, restart Zope/Plone, and install the Plone4ArtistsCalendar (p4a.plonecalendar) and Recurring Events (p4a.ploneevent) products in Site Setup → Add-on Products.
Now that everything is installed, we apply a monthly calendar view to the Events collection:
- Navigate back to the Events collection, and choose Calendar from the new Sub-types menu.
- If it isn’t already selected, choose Month view from the Display menu.
Presto—we have a monthly calendar showing every event on our site.