Skip to content
OpenCms documentation
OpenCms documentation

Event series

Since OpenCms 11, has support for managing a whole series of events in a single content. E.g., you have a guitar course taking place ten times, you can simply add one XML content describing your course and adding all dates via a special widget.

In lists, listing your upcoming events, the course will appear for each instance once, and also when linking to detail pages you can manage to show the correct date for the specific date of the one course meeting.

For the event series, each event in the series will be indexed (and thus found in a search) at its own. Here, the special handling on indexing is described.

The widget to easily edit a date series.

The bean you access a date series with in a JSP.

The bean wrapping a single event instance' date (with start and end time).

To make your content handle a series of events, you add a schema node of type OpenCmsSerialDate:

Configuration of a series in the schema of a content type

<xsd:element name="Dates" type="OpenCmsSerialDate" />
Learn about writing schemas here.

When using this schema element type, the SerialDateWidget will be used for the element in the content editor:

The serial date widget

To access a date series in a formatter use

<c:set var="dates" value="${content.value.Dates.toDateSeries}" />

You obtain an object of type CmsJspDateSeriesBean that allows for easy access to the dates. The bean has multiple useful properties. Look it up in the JavaDoc.

When you collect your events in a list built with Solr, you will get each single event listed. The current event instances start date is stored in the Solr document's field instancedate_{locale}_dt. The date series bean provides access to the single instance via ${dates.instanceInfo[{start date}}, where {start date} is what you get from instancedate_{locale}_dt. In combination. you could have a list formatter like this:

<%-- ... --%>
<cms:simplesearch var="search" ... />
<c:forEach var="result items="${search.searchResults}">
  <cms:display ...>
     <cms:param name="instancedate">${result.dateFields[instancedatefield].time}</cms:param>
  </cms:display>
</c:forEach>
<%-- ... --%>

where <cms:display> renders your event with a display formatter, that gets the instance date as parameter (or element setting) instancedate and might render like:

<%-- ... --%>
<c:set var="instancedate"           value="${param.instancedate}" />
<c:set var="seriesInfo"             value="${content.value.Dates.toDateSeries}" />
<c:set var="date"                   value="${seriesInfo.instanceInfo.get(instancedate)}" />
<h3><a href="<cms:link>${content.filename}?instancedate=${instancedate}</cms:link></h3>
<p>From ${date.formatShort}</p>
<%-- ... --%>

Note, that in the link to the detail page, we again add the parameter ?instancedate=${instancedate}. Hence, we can use it in a detail formatter similarly as here in the display formatter.

Note that here we use a structure for a list as described for building lists with OpenCms 11. You do not have to use display formatters and could also use <cms:search> instead of <cms:simplesearch>. E.g., when searching events in a full-text search.