The OpenCms 8 Demo Template Modules in Detail

From OpenCms Wiki
Revision as of 11:19, 30 August 2011 by Alkacon (Talk | contribs)
Jump to: navigation, search



With OpenCms 8 come not one but two sets of demo templates - the simple Dev Demo "Basic Template" (BT) and the more advanced "Template III" (T3) module. These modules are a versatile starting point for building custom websites.

T3 has been developed to be a solid and feature rich foundation for the creation of individual OpenCms websites. BT is limited in functionality and design, but makes a good reference for developers looking at the source code since its structure is rather simple and straightforward.

This tutorial shows examples of sites that can be built with OpenCms 8 using T3 and explain configuration options and possible extensions of this template.

This tutorial goes into details of the code structure and VFS layout used for T3, as many "best practices" learned by Alkacon have been used in this template module. It shows why T3 is a good starting point for development of custom websites.

Functions of T3 get compared to BT, to point out areas in which design and functionality requirements can lead to certain development decisions.

Template comparison OpenCms 6, 7 and 8

OpenCms 6 and 7

Template One
Template Two
  • OpenCms 6
  • OpenCms 7
  • Manyfeatures
  • Very complicated
  • Based on a project for a customer
  • Difficultto understand
  • Combined template features and demo examples
  • Template and resources are part of the same module
  • Still not easy to understand
  • For simple websites

OpenCms 8

  • Template III
    • The best pratice using OpenCms 8
    • Can be directly used for website development
    • Loose coupling of template and content types modules
    • As a starting point for a web-project
  • Dev Demo
    • Well documented easy to understand Use Cases
    • Playground for template developers

Template III and content modules

Demo Modules

  • OpenCms 8 Template III frontend
    • Navigation
    • Configurable Layout
  • No dependency between template module and the content types:
    • OpenCms 8 Article
    • OpenCms 8 News
    • OpenCms 8 Event
    • OpenCms 8 List
    • OpenCms 8 Login
    • OpenCms 8 Search
    • OpenCms 8 Twitter

OpenCms 8 Template III

  • Main navigation, left navigation, breadcrumb


  • <cms:navigation>
  • Attributes:
    • type: treeForFolder, forFolder, forSite, forResource, breadCrumb
    • startLevel: property "NavStartLevel" on resource or folder
    • endLevel
    • var
 <c:set var="navStartLevel" >
   <cms:property name="NavStartLevel" file="search" default="0" />
 <cms:navigation type="forFolder" startLevel="${navStartLevel}" var="nav"/>
   <c:forEach items="${nav.items}" var="elem">
     <c:set var="currentLevel" value="${elem.navTreeLevel}" />
     <a href="<cms:link>${elem.resourceName}</cms:link>">
  • Configurable Header and Footer


  • Drop header and footer to the model containerpage
    • /_contents/_new/pages/default.html
  • Edit the xmlcontent to add the required html
    • Header: html of the header content
    • Footer: html of the footer content
  • Reminder: Set the path to the model containerpage in the sitemap configuration
    • /_config/sitemap_restype.config
  • Defines 2-or 3-columns layout
  • Use property "Template columns" by editing properties of the container page directly in the sitemap.


  • Xmlcontent as configuration
  • t3style
  • Color settings of the template
    • /_config/style


  • Set properties on the site folder or on a single page:
  • Template code:
     <link href=
             cols=<cms:property name='style.layout' file='search' />&
             style=<cms:property name="style.columns" file="search" default="3" />
     </cms:link>" rel="stylesheet" type="text/css">

OpenCms 8 Article


  • v8article
  • Content
    • Title
    • Paragraph (Headline, Text, Image)
    • Category
  • XSD: Image Alignment
  • Settings:
    • Image Alignment
    • Box Schema (Color)

OpenCms 8 Event, News

  • v8news, v8event
  • Extended article content
  • Event:
    • Event data like start and end date, location
    • Availability with release and expiration
  • News
    • Author name and e-mail
    • Availability with release and expiration
  • Settings:
    • Image Alignment
    • Box Schema (Color)
    • Show location(only event), Show time

Article - Image alignment

Image Alignment:

  • Left of text
  • Right of text
  • Top
  • Left of headline
  • Right of headline


  • For each content
  • As default alignment


  • For each element


  • XSD configuration:
 <xsd:schema xmlns:xsd=… >
   <xsd:element name="V8Articles" type="OpenCmsV8Articles"/>
         <setting name="imgalign"
           nice-name="Image Align"
           widget-config="left : %(key.v8.article.image.left) | right : %(key.v8.article.image.right)|[..]" />
  • Formatter:
 <c:set var="imgalign">
   <cms:elementsetting name="imgalign" default="left" />
   <c:when test="${imgalign== 'left'}">
     <c:set var="imgclass">left</c:set>
   <c:when test="${imgalign== 'right'}">
     <c:set var="imgclass">right</c:set>

Event – Show location

  • Configuration in the XSD file:
   <setting name="showlocation"
     nice-name="Show location"
  • Available setting widgets:
    • string, select, datebox, vfslink, checkbox, multiselect, radio

Dynamic configurable list


  • v8list
  • List of resources
  • Title / top and bottom text
  • Collector configuration
  • Mapping configuration

OpenCms 8 List - Collector

  • Define the resources to display in the dynamic list
    • Choose one of the available collectors
    • Set the collector parameter

/_contents/events/e_%(number).html|v8event|2 The path to resources to collect |Resource type | Number of resources

  • Link validation
    • Set the vfslink to the resource folder
    • Use macro as collector parameter


OpenCms 8 List - Mapping

  • Mapping configuration
    • Position: Author, Date, Image
    • Mapping: Field -> Xml node of the chosen resource type
    • Max length of the text


OpenCms 8 Login Form


  • v8login
  • Content:
    • Title
    • Text
  • Login form
  • Log in for a protected area on the website

OpenCms 8 Search Form


  • v8search
  • Content:
    • Title
    • Text
    • No results
    • Error
  • Search configuration
    • Search Index
    • Search source
    • Matches pro page
  • Fulltext search on the website
  • Using search form:
    • Drop a search form to the left or right column
    • Add a new search form (detail*) page in the sitemap
    • Make detail default
  • Now the search results are displayed on the detail page

OpenCms 8 Twitter Feed


  • v8twitter
  • Official twitter widget
  • XmlContent
    • Title
    • User
    • Backgroundcolor
    • Links Color
  • Settings:
    • Twitter box height
  • Dynamic include of additional javascriptand css
  • Add new tag to the template <head> :
   <cms:headincludes type="javascript" />
   <cms:headincludes type="css" />
  • Add new node in the content xsd:
       <headinclude type="javascript" uri="" />
       <headinclude type="css" uri="/system/modules/…/resources/css/style.css"/>
  • Formatter:
 <cms:formatter var="content" val="value">

Dev Demo Template

  • Using and customizing Demo Templates
    • Customize Template III
    • Header and Footer
    • Stylesheet for the site or sub sites
    • 2 or 3 columns
    • Flexible image alignment
    • Individual settings for elements
    • Dynamic elements like lists, twitter feed and search
  • Extensibility of content types
    • New formatter for content types
    • New settings to control layout and content of element
    • Additional javascript or css with <cms:headinclude> tag
    • Create new content type module to use with Template III
    • Use available content module as a copy model
Important:Check the resource type ids
Personal tools