opencms 标签

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:

<!-- <TR> <TD class=defcode align=middle>pageSize</TD> <TD class=deftext> <P>This attribute specifies the size (= number of list items) of a list page to browse through a list of XML contents. </P> <P>It is a good style to specifiy the page size as a property, e.g.:</P> <P>&nbsp;</P> <DT><B>%(property.pageSize)</B> <DD>Will be replaced by the&nbsp;value of the property "pageSize"&nbsp;</DD> </TD></TD></TR><TR> <TD class=defcode align=middle>pageIndex</TD> <TD class=deftext> <P>This attribute specifies the index to the current page to be viewed while browsing through the a list of XML contents. </P> <P>Usually the page index is specified by a Http request parameter, e.g.:</P> <P>&nbsp;</P> <DT><B>${param.pageIndex}</B> <DD>Will be raplaced by the&nbsp;value of the property "pageSize"&nbsp;</DD> </TD></TD></TR> //-->
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.
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>

你可能感兴趣的:(html,jsp,cms,xml)