`
lan13217
  • 浏览: 507012 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

opencms <cms:contentload>标签

    博客分类:
  • cms
阅读更多

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>
分享到:
评论

相关推荐

    opencms建站手册

    例如,要从数据库中获取一个内容并显示在页面上,可以使用&lt;cms:contentload&gt;标签,配合API中的ContentManager类来实现。 2.3 常用API 2.3.1 常见对象和方法 ContentManager是访问内容的主要接口,其方法如...

    opencms指南

    - `&lt;CMS:CONTENTLOAD&gt;`:加载内容。 - `&lt;CMS:CONTENTCHECK&gt;`:检查内容状态。 - `&lt;CMS:CONTENTLOOP&gt;`:循环遍历内容。 - `&lt;CMS:CONTENTSHOW&gt;`:显示内容。 - `&lt;CMS:EDITABLE&gt;`:标记可编辑区域。 - `&lt;CMS:INFO...

    opencms资料

    - **&lt;CMS:CONTENTLOAD&gt;**:加载内容。 - **&lt;CMS:CONTENTCHECK&gt;**:检查内容状态。 - **&lt;CMS:CONTENTLOOP&gt;**:循环显示内容。 - **&lt;CMS:CONTENTSHOW&gt;**:显示内容详情。 - **&lt;CMS:EDITABLE&gt;**:使内容可编辑。 - **...

    OpenCms中文指南

    - `&lt;CMS:CONTENTLOAD&gt;`: 加载内容。 - `&lt;CMS:CONTENTCHECK&gt;`: 检查内容状态。 - `&lt;CMS:CONTENTLOOP&gt;`: 循环遍历内容集合。 - `&lt;CMS:CONTENTSHOW&gt;`: 显示内容。 - `&lt;CMS:EDITABLE&gt;`: 允许编辑内容。 - `&lt;CMS:...

    OpenCms 带分页的新闻列表

    `&lt;cms:contentload&gt;` 是OpenCms提供的核心标签之一,用于加载内容。在这个例子中,我们使用它来获取指定路径 `/test/news_%(number).html` 下的 `testnews` 类型的新闻内容。`%(number)` 是OpenCms的变量替换语法,...

    OpenCMS内容管理入门指南(300页中文).pdf

    ##### 5.7 &lt;CMS:CONTENTLOAD&gt; - **作用**: - 加载指定ID的内容项。 ##### 5.8 &lt;CMS:CONTENTCHECK&gt; - **功能**: - 检查内容是否存在或是否可编辑。 ##### 5.9 &lt;CMS:CONTENTLOOP&gt; - **用途**: - 遍历一组内容项,...

    OpenCMS教程

    **5.7 &lt;CMS:CONTENTLOAD&gt;** - 加载特定内容。 **5.8 &lt;CMS:CONTENTCHECK&gt;** - 检查内容的有效性。 **5.9 &lt;CMS:CONTENTLOOP&gt;** - 循环遍历一组内容。 **5.10 &lt;CMS:CONTENTSHOW&gt;** - 显示单个内容项。 **5.11 &lt;CMS:...

Global site tag (gtag.js) - Google Analytics