Get the CmsObject

From OpenCms Wiki
(Difference between revisions)
Jump to: navigation, search
m
m (changed lang to xml)
 
(3 intermediate revisions by one user not shown)
Line 1: Line 1:
 
The CmsObject gives you access to many of OpenCMS' features.
 
The CmsObject gives you access to many of OpenCMS' features.
  
<source lang="java">
+
===Getting the CmsObject in scriptlets===
 +
 
 +
<source lang="xml">
 
   <%@page import="org.opencms.file.CmsObject"%>
 
   <%@page import="org.opencms.file.CmsObject"%>
 
   <%@page import="org.opencms.jsp.CmsJspActionElement"%>
 
   <%@page import="org.opencms.jsp.CmsJspActionElement"%>
Line 10: Line 12:
 
       ... do something useful
 
       ... do something useful
 
   %>
 
   %>
 +
</source>
 +
 +
===Getting the CmsObject using EL===
 +
<source lang="xml">
 +
  <%@taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
 +
 +
  <c:set var="co" value="${cms:getCmsObject(pageContext)}" />
 +
  <%-- ... do something useful --%>
 
</source>
 
</source>
  
 
[[Category:Developing in OpenCms ]]
 
[[Category:Developing in OpenCms ]]

Latest revision as of 10:44, 24 August 2012

The CmsObject gives you access to many of OpenCMS' features.

Getting the CmsObject in scriptlets

   <%@page import="org.opencms.file.CmsObject"%>
   <%@page import="org.opencms.jsp.CmsJspActionElement"%>
   <%
      CmsJspActionElement jsp = new CmsJspActionElement(pageContext, request, response);
      CmsObject cms = jsp.getCmsObject();
 
      ... do something useful
   %>

Getting the CmsObject using EL

   <%@taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
 
   <c:set var="co" value="${cms:getCmsObject(pageContext)}" />
   <%-- ... do something useful --%>
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox