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.

Configuration of a series in the schema of a content type

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

<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:

Accessing a date series in a formatter

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.

Lists and links to detail pages

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>
<%-- ... --%>

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.

You can improve this page

Please contribute your suggestions or comments regarding this topic on our wiki. For support questions, please use the OpenCms mailing list or go for professional support.