`
lan13217
  • 浏览: 495988 次
  • 性别: 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;opencms:contentquery&gt;`标签将根据这些参数来执行分页查询。 此外,OpenCMS还提供了一些辅助方法,例如计算总页数和判断是否为首页或尾页,以便在JSP中生成正确的导航链接。这通常会涉及一些逻辑判断,例如: ``...

    opencms开发指南

    &lt;xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/&gt; &lt;!-- 定义了一个名为 Cntvs 的元素 --&gt; &lt;xsd:element name="Cntvs" type="OpenCmsCntvs"/&gt; &lt;!-- 定义了 OpenCmsCntvs 类型 --&gt; &lt;xsd:...

    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; - **用途**: - 遍历一组内容项,...

    cms内容管理手册中文版

    - 常用标签:详细解释了如&lt;CMS:USER&gt;、&lt;CMS:PROPERTY&gt;、&lt;CMS:LINK&gt;等标签的使用方法,以及如何创建导航条、导航列表等。 6. FLEXCACHE缓存机制: - FLEXCACHE介绍:介绍了FLEXCACHE缓存机制的作用,包括实例和...

    opencms整理

    OpenCMS 是一款基于 Java 和 JSP 的开源内容管理系统(Content Management System, CMS)。它可以帮助用户轻松地构建、管理和发布网站内容。OpenCMS 提供了丰富的功能,如多语言支持、工作流管理、版本控制等,适用于...

    OpenCms创建网站过程图解——献给OpenCms的初学者们

    CHARSET=&lt;cms:property name="content-encoding" default="UTF-8"/&gt;"/&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;测试网站的模板&lt;/h2&gt; &lt;cms:include element="body"/&gt; &lt;/body&gt; &lt;/html&gt; ``` 这个模板使用了OpenCms的标签库来动态...

    OpenCMS内容管理系统入门教程

    - `&lt;cms:contentloop&gt;`:用于循环展示内容集合。 - **对象模型**: - 介绍了OpenCMS的对象模型及其用途。 - 包括文件、目录、用户等基本对象的管理。 - **配置文件作用**: - `workplace.properties`文件用于...

    如何安装OPENCMS

    &lt;Context docBase="C:/Program Files/OpenCms/webapps/opencms" path="/opencms" debug="0" reloadable="true"/&gt; ``` 5. **配置数据库连接**:修改OPENCMS的`WEB-INF/classes/opencms-system.xml`文件,配置...

    opencms静态导出配置

    &lt;rfs-prefix&gt;${CONTEXT_NAME}/export&lt;/rfs-prefix&gt; &lt;!-- 设置静态导出预览前缀(Offline下链接地址前缀) --&gt; &lt;vfs-prefix&gt;${CONTEXT_NAME}${SERVLET_NAME}&lt;/vfs-prefix&gt; &lt;!-- 设置静态导出时是否使用相对...

    marmots-opencms-maven-plugin:一个帮助 Opencms 模块开发的 Maven 插件

    &lt; url&gt;smb://Admin:admin@localhost:1446/OPENCMS/&lt;/ url&gt; &lt; module&gt;org.marmots.opencms.samplesite&lt;/ module&gt; 套餐目标 生成 opencms 模块 manifest.xml 并将其与所有资源、类和库打包在一起。 配置属性 &lt; module...

Global site tag (gtag.js) - Google Analytics