Using formatters in OpenCms

From OpenCms Wiki
Revision as of 13:09, 29 July 2011 by Alkacon (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Abstract

This document explains the concept of formatters used in OpenCms since Version 8.0.0. This concept replaces the <cms:contenload> and <cms:contentacces> tag used in older OpenCms versions. It is not backwards compatible.

Template

A page layout is defined in the template JSP. A page can have multiple containers where XML content of different resource types can be moved to by Drag & Drop in the ADE. Containers can be defined by using the <cms:container> tag in your template JSP.

<html>
 <head>
  ...
  <cms:enable-ade />
 </head>
 <body>
  ...
  <cms:container name="LEFTCOLUMN" type="sidecolumn" width="200" />
  <cms:container name="CENTERCOLUMN" type="center" width="500" />
  <cms:container name="RIGHTCOLUMN" type="sidecolumn" width="200" />
  ...
 </body>
</html>

Formatter configuration

Formatters are defined in the XML Schema Definition of the container page resource type. Formatters get defined in the <formatters> node within the <xsd:appinfo> node of the XSD of the content. A formatter defines which formatter JSP should be used to render the XML content.

<xsd:annotation>
 <xsd:appinfo>
  ...
  <formatters>
   <formatter minWidth="400" maxWidth="700" uri="path to formatter JSP" />
   ...
  </formatters>
 </xsd:appinfo>
</xsd:annotation>

The same XML Content can be rendered by different formatter JSPs. Which formatter JSP is used for which container can be configured in the resource type schema. The formatter is chosen by the given container width or container type.

<xsd:annotation>
 <xsd:appinfo>
  ...
  <formatters>
   <formatter minWidth="100" uri="path to formatter JSP" />
   <formatter minWidth="400" maxWidth="700" uri="path to formatter JSP" />
   ...
  </formatters>
 </xsd:appinfo>
</xsd:annotation>
<xsd:annotation>
 <xsd:appinfo>
  ...
  <formatters>
   <formatter type="center" uri="path to formatter JSP" />
   <formatter type="sidecolumn" uri="path to formatter JSP" />
   ...
  </formatters>
 </xsd:appinfo>
</xsd:annotation>

The <cms:formatter> tag

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox