The <cms:contentload>
tag
This tag loads a collection of xml content resources. Depending on the collector given in the collector attribute, either a single xml content resource or a list of resources is loaded which will be looped in this tag.
Attributes:
Name | Description | Required |
collector | The collector to read the xml content resources. Collectors are defined in java classes which are configured in the opencms-vfs.xml configuration file. OpenCms contains already a class CmsDefaultResourceCollector which is an aggregation of the following collectors: singleFile
Other collectors are available in the class CmsPriorityResourceCollector which sorts resources by the values of the properties "collector.priority" and "collector.date". The following collectors can be used from this class: allInFolderPriorityDateDesc
Instead of specifying the collector name hardwired in the collector attribute, the name of the collector can also be specified in a macro expression telling the attribute to read the collector name from a property "collector" on the JSP page, e.g.: %(property.collector) | yes |
param | The param attribute is used to give additional information to the collector. When using one of the collectors in CmsDefaultResourceCollector, the param attribute provides additional information about the resource name of xml content resources to be read by the collectors. The format of this parameter is: "[filename]|[resource type]|[count]"
Again you are free to use macro expressions in the param attribute to set the value of the collector's param, e.g.: %(property.xml-content)
| |
editable | This attribute defines if the xml content supports the direct edit feature. The following values are supported:
| |
preload | This attribute defines if the collector will proload itts content. This is required to check if the collector has returned any results at all, which can be done in combination with the The following values are supported: true Activates the preload |
Body:
Any HTML, JSP or JSTL code of your template, this code will be looped if the selected collector will return more than one xml content items.
Example usage:
A detail view of a xml content resource would use a contentload tag as following:
<cms:contentload collector="singleFile" param="%(opencms.uri)" editable="true"> ... </cms:contentload>
An example to read all xml content resources of the resource type 11 in a sub tree starting with the folder "/xml-content/" in the current site. You need to set a property "collector" with the value "allInSubTree" on the JSP, together with a property "xm-content" with the value "/xmlcontent/":
<cms:contentload collector="%(property.collector)" param="%(property.xml-content)article_%(number).html|11" editable="true" preload="true"> ... </cms:contentload>
An example for preloading content and check if there are any results returned.
<cms:contentload collector="%(property.collector)" param="%(property.xml-content)article_%(number).html|11" editable="true"> <cms:contentinfo var="info" /> <!-- use "info" for validation --> <c:if test="${info.resultSize > 0}"> <cms:contentload> <!-- the nested contentload must be used to display the xml content --> </cms:contentload> </cms:contentload>