To make your content handle a series of events, you add a schema node of type OpenCmsSerialDate
:
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
<xsd:element name="Dates" type="OpenCmsSerialDate" />
When using this schema element type, the SerialDateWidget will be used for the element in the content editor:
<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.
<cms:search>
instead of <cms:simplesearch>
. E.g., when searching events in a full-text search.