Description

The CmsVelocityTemplateHelper is a Velocity Context Object for the OpenCms Module "at.infonova.opencms.modules.velocity" from Infonova Gmbh.

OpenCms is a Content Management System that is based on Open Source Software. Complex Intranet and Internet websites can be quickly and cost-effectively created, maintained and managed.

Config

This ContextObject must be configured in "WEB-INF/config/infonova-velocity.xml".

The entry could look like the following:

<opencms>
  <velocity>
    <velocity-context-objects>
      [...]
      <velocity-context-object
        name="velocity"
        factory-class="at.infonova.opencms.modules.templatehelper.CmsVelocityTemplateHelper$Factory" />
    </velocity-context-objects>
  </velocity>
</opencms>

After configuration the ContextObject a reboot of OpenCms is required.

Example Usage

After configuration the ContextObject it is available in all Velocity templates which are parsed by the OpenCms Module "at.infonova.opencms.modules.velocity" from Infonova Gmbh.

The default prefix of this ContextObject should be 'velocity'.

After that, the following Methods are available:

  • ${cms.help} => This helptext.
  • ${cms.link(java.lang.String)} => The same as <cms:link ... /> from OpenCms Taglib.
  • ${cms.content} => The Xml Content of the current Resource (request uri) as POJO. The same as ${cms.fileContent(cms.requestContext.uri)}.
  • ${cms.template} => Return the Xml Content of the XML-Template as POJO. Nearly the same as ${cms.fileContent($cms.property.template)}.
  • ${cms.fileContent(java.lang.String)} => The Xml Content of the given Resource as POJO. The file must be a structured Content (xmlContent) or a XmlPage.
  • ${cms.property} => Properties of the current Resource (request uri) as Map. The same as ${cms.fileProperty($cms.requestContext.uri)}. Example: ${cms.property.template.value} returns the value of CmsProperty 'template' of the current resource.
  • ${cms.fileProperty(java.lang.String)} => Properties of the given Resource as Map. Example: ${cms.fileProperty($cms.requestContext.uri).template.value} returns the value of CmsProperty 'template' of the current resource.
  • ${cms.requestContext} => Returns the current users request context.
  • ${cms.fileResourceType(java.lang.String)} => Returns the I_CmsResourceType of the given Resource. Example: ${cms.fileResourceType($cms.property.template).typeName}.
  • ${cms.resourceType} => Returns the I_CmsResourceType of the current Resource (request uri). Example: ${cms.resourceType.typeName}. The same as: ${cms.fileResourceType($cms.requestContext.uri).typeName}.
  • ${cms.fileResource(java.lang.String)} => Returns the CmsResource of the given Resource. Example: ${cms.fileResource($cms.property.template).resourceId}.
  • ${cms.resource} => Returns the CmsResource of the current Resource (request uri). Example: ${cms.resource.resourceId}. The same as: ${cms.fileResource($cms.requestContext.uri).resourceId}.
  • ${cms.filePathLevel(java.lang.String)} => Returns the directory level of the given Resource path. Example: ${cms.filePathLevel('/foo/index.html')}.
  • ${cms.pathLevel} => Returns the directory level of the current Resource (request uri). Example: ${cms.pathLevel}. The same as: ${cms.filePathLevel($cms.requestContext.uri)}.
  • ${cms.randomUUID} => Returns a new random UUID. This is useful for HTML-TAG-Ids and accessing it from javascript.
  • ${cms.encoding} => Returns the 'content encoding' property value of the requested uri.
  • ${cms.childFolderPaths(java.lang.String)} => Returns the list of the child folders for the given resourcePath.
  • ${cms.navigationBreadcrumb(int)} => Returns the Breadcrumb as List of CmsJspNavElement for the given startLevel.
  • ${cms.navigationForFolder(java.lang.String)} => Returns the List of CmsJspNavElement in the given folder.
  • ${cms.navigationSiteMap(java.lang.String)} => Returns the complete navigation site tree as List of CmsJspNavElement starting from the given path.
  • ${cms.navigationLevel(int)} => Returns the List of CmsJspNavElement for the given level in the current request uri.