EL functions provided by OpenCMS taglib
(Difference between revisions)
(New page: The OpenCMS taglib provides tags, but also functions. You can see their definition in the '''WEB-INF/opencms.tld''' file. Just decalre the taglib as usual: <nowiki><%@ taglib prefix="cms...) |
|||
Line 1: | Line 1: | ||
− | The OpenCMS taglib provides tags, but also functions. You can see their definition in the '''WEB-INF/opencms.tld''' file. | + | The OpenCMS taglib provides tags, but also functions. You can see their definition in the '''WEB-INF/opencms.tld''' file, |
− | Just | + | the functions themselves are provided by the [http://www.opencms.org/javadoc/core/index.html?org/opencms/jsp/util/CmsJspElFunctions.html CmsJspElFunctions] class. |
+ | |||
+ | Just declare the taglib as usual: | ||
<nowiki><%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %></nowiki> | <nowiki><%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %></nowiki> | ||
Line 9: | Line 11: | ||
${cms:vfs(pageContext).context.locale} | ${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: | ||
+ | |||
+ | <source lang="xml"> | ||
+ | <%@ 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" /> | ||
+ | </source> |
Revision as of 10:56, 20 September 2010
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" />