Cms:contentload

(Difference between revisions)
Jump to: navigation, search
(Collectors)
Line 25: Line 25:
 
* '''allInSubTreeDateAsc''': Gets all resources in a folder and its subfolders sorted in ascending order by their creation date. The sorting can be adapted in the param attribute.
 
* '''allInSubTreeDateAsc''': Gets all resources in a folder and its subfolders sorted in ascending order by their creation date. The sorting can be adapted in the param attribute.
 
* '''allInSubTreeDateDesc''': Gets all resources in a folder and its subfolders sorted in descending order by their creation date. The sorting can be adapted in the param attribute.
 
* '''allInSubTreeDateDesc''': Gets all resources in a folder and its subfolders sorted in descending order by their creation date. The sorting can be adapted in the param attribute.
 +
* '''allInFolderPriorityDateAsc''' and '''allInFolderPriorityDateDesc''' - Get all resource in a folder sorted by priority, then date ascending or descending - see [http://files.opencms.org/javadoc/core/org/opencms/file/collectors/CmsPriorityResourceCollector.html CmsPriorityResourceCollector.allInFolderPriorityDate() javadoc]
  
 
== Params ==
 
== Params ==

Revision as of 10:14, 30 May 2014

There is only a little documentation regarding usage of cms:contentload. This document hopes to expand on that.

Contentload is a tag that will let you load a CMS resource as an object, and manipulate it using jsp tags. More detail is available in the documentation included with OpenCms.

Here is an example where an asterisk is used for pattern matching in the param section:

  <cms:contentload collector="allInFolderPriorityDateDesc" param="${opencms.folder}news${*}.html|news|15" editable="true">
    <%-- create a date object from date value --%>	
    <li>
      <a href="<cms:link><cms:contentshow element="${opencms.filename}" /></cms:link>" title="<cms:contentshow element="Title" />"></a>
      <p><cms:contentshow element="Teaser" /></p>
    </li>
  </cms:contentload>

Important note, if you are running OpenCms 7 or newer, use %(opencms.folder), %(opencms.filename), etc, since the macro syntax is now "%()".

Find more informations about which collector parameters exist and how they work in the source code at org.opencms.file.collectors.*, e.g. CmsDefaultResourceCollector.

Collectors

This section describes a few collectors. You can also find all this in the source code as described above.

  • allInFolderDateReleasedDesc: This gets all resources in a folder sorted in descending order by their publish date.
  • allInFolderDateDesc: This gets all resources in a folder sorted in descending order by their creation date. Type of resource needed and number can be specified in the collector parameter.
  • allInSubTreeDateAsc: Gets all resources in a folder and its subfolders sorted in ascending order by their creation date. The sorting can be adapted in the param attribute.
  • allInSubTreeDateDesc: Gets all resources in a folder and its subfolders sorted in descending order by their creation date. The sorting can be adapted in the param attribute.
  • allInFolderPriorityDateAsc and allInFolderPriorityDateDesc - Get all resource in a folder sorted by priority, then date ascending or descending - see CmsPriorityResourceCollector.allInFolderPriorityDate() javadoc

Params

The param attribute defines which files are listed give you also some power to sort the resulting list.

The sytax is the following:

<cms:contentload param="<the target cms folder>|name-of-your-open-cms-content-type|<how many items to display>|<optional atribute used for the sort compare>" [rest of attributes]>

For example: This will display all items of the type es-calendar-entry in the folder ${calendar.value.Source} and be sorted by the date attribute of the file (it can be mapped from the input field attributes of the content type).

<cms:contentload param="${calendar.value.Source}|es-calendar-entry|${numberOfEvents}|collector.date" [rest of attributes]>
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox