EL functions provided by OpenCMS taglib

From OpenCms Wiki
Revision as of 10:56, 20 September 2010 by Makub (Talk | contribs)
Jump to: navigation, search

The OpenCMS taglib provides tags, but also functions. You can see their definition in the WEB-INF/opencms.tld file, the functions themselves are provided by the CmsJspElFunctions class.

Just declare the taglib as usual:

<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>

cms:vfs

Provides access to VFS (Virtual File System), returns an instance of org.opencms.jsp.util.CmsJspVfsAccessBean. Example:

${cms:vfs(pageContext).context.locale}

cms:convertDate

Allows conversion of Long values to Dates. For example to display the time of last modification of a page:

<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
...
 <f:formatDate 
  value="${cms:convertDate(cms:vfs(pageContext).resource[cms:vfs(pageContext).context.uri].dateLastModified)}" 
  pattern="yyyy-MM-dd HH:mm:ss" />
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox