<< Back - Alkacon logo

OpenCms 6.0 interactive documentation:

Documentation for the 'cms:contentload' tag

OpenCms logo - Forward >>

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 

Gets a single xml content resource. The name of the resource is given in the param attribute.
allInFolder
Gets a list of all xml content resources of a folder. The folder name is given in the param attribute.
allInFolderDateReleasedDesc 
Gets a list of all xml content resources of a folder, sorted by the release date. The folder name is given in the param attribute.
allInFolderNavPos 
Gets a list of all xml content resources of a folder, sorted by the "NavPos" property value. The folder name is given in the param attribute.
allInSubTree
Gets a list of all xml content resources of a sub tree. The tree root is given in the param attribute.
allInSubTreeDateReleasedDesc 
Gets a list of all xml content resources of a sub tree, sorted by the release date. The tree root is given in the param attribute.
allInSubTreeNavPos 
Gets a list of all xml content resources of a sub tree, sorted by the "NavPos" property value. The tree root is given in the param attribute. 

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

Gets a list of all xml content resources of a folder, sorted by the "collector.priority" property. If resources have the same priority, the "collector.date" property is used as second sorting criteria. The folder name is given in the param attribute.
allInFolderPriorityTitleDesc
Gets a list of all xml content resources of a folder, sorted by the "collector.priority" property. If resources have the same priority, the "Title" property is used as second sorting criteria. The folder name is given in the param attribute.
allInSubTreePriorityDateDesc 
Gets a list of all xml content resources of a sub tree, sorted by the "collector.priority" property. If resources have the same priority, the "collector.date" property is used as second sorting criteria. The tree root is given in the param attribute.
allInSubTreePriorityTitleDesc
Gets a list of all xml content resources of a sub tree, sorted by the "collector.priority" property. If resources have the same priority, the "Title" property is used as second sorting criteria. The tree root is given in the param attribute.

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]"

 

[filename] 
The name of the resource to load, it can include a makro value "${number}", which replaced with the number of the the next xml content resource while looping through the single elements.
[resource type]
One of the resource types of xml contents defined in the opencms-vfs.xml configuration file.
[count]
Will use the current uri in the OpenCms VFS as resource name. Its typical to use this with the singleFile collector a detail view jsp.
 

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}

Will be replaced by the value of the property "xml-content"
${opencms.uri} 
Will be replaced by the current OpenCms VFS URI. Its typical to use this with the singleFile collector a detail view jsp.
${opencms.filename}
Will be replaced by the resource name of the current xml content resource while looping through the single resources.
${param.resourceType} 
Will be replaced by the value of the Http reuest parameter "resourceType.
editable

This attribute defines if the xml content supports the direct edit feature.

The following values are supported:

true
The xml content can be edited from the frontend directly.
false (default)
The xml content cannot be edited from the frontend directly. This is the default if the attribute is not set.

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">
...
<cms:contentload />

©2003-2005 Alkacon Software (http://www.alkacon.com) - The OpenCms experts