info.magnolia.cms.taglibs
Class CmsFunctions

java.lang.Object
  extended by info.magnolia.cms.taglibs.CmsFunctions

public class CmsFunctions
extends Object

Useful EL functions that can be used in jsp 2.0 pages.

Version:
$Revision: $ ($Author: $)
Author:
fgiust

Constructor Summary
CmsFunctions()
           
 
Method Summary
static boolean canEdit()
          Check if the current user can edit the active page.
static Content currentPage()
          Returns the current active page (can be set using the loadPage tag).
static Content currentParagraph()
          Returns the current paragraph.
static boolean firstPageWithCollection(String collectionName, int minlevel)
          Find and load the first parent page containing a named collection of nodes.
static boolean firstPageWithNode(String nodeName, int minlevel)
          Find and load the first parent page containing a named node.
static boolean isEditMode()
          Check if the current page is open in editing mode.
static boolean isLoggedIn()
          Check if a user is currently logged in (not anonymous).
static String link(String handle)
          Output a full url given a content handle (usually a page).
static Content mainPage()
          Returns the main loaded page (doesn't change when using the loadPage tag).
static Collection nodeDataIterator(Content c, String collection)
          Function to iterate over a node Data that has "checkbox" as control type, for example.
static Properties systemProperties()
          Returns the system properties.
static String systemProperty(String key)
          Returns the value of a system property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsFunctions

public CmsFunctions()
Method Detail

currentPage

public static Content currentPage()
Returns the current active page (can be set using the loadPage tag).

Returns:
current page

mainPage

public static Content mainPage()
Returns the main loaded page (doesn't change when using the loadPage tag).

Returns:
loaded page

currentParagraph

public static Content currentParagraph()
Returns the current paragraph.

Returns:
current paragraph

link

public static String link(String handle)
Output a full url given a content handle (usually a page).

Parameters:
handle - page handle
Returns:
url formed using context path + handle + default extension

systemProperty

public static String systemProperty(String key)
Returns the value of a system property.

Parameters:
key - property key
Returns:
property value

systemProperties

public static Properties systemProperties()
Returns the system properties.

Returns:
Property instance

isLoggedIn

public static boolean isLoggedIn()
Check if a user is currently logged in (not anonymous).

Returns:
true if a user is currently logged in.

canEdit

public static boolean canEdit()
Check if the current user can edit the active page.

Returns:
true if the current user can edit the active page.

isEditMode

public static boolean isEditMode()
Check if the current page is open in editing mode. Shortcut for checking if the server is admin, preview unset, permissions to modify the page available for the current user.

Returns:
true if the page is open in edit mode and user has permissions to edit

firstPageWithCollection

public static boolean firstPageWithCollection(String collectionName,
                                              int minlevel)
Find and load the first parent page containing a named collection of nodes. This function can be useful while building pages that should inherit columns from parent pages. Loaded page must be unloaded using the <cms:unloadPage /> tag. Sample use:
 <c:if test="${cmsfn:firstPageWithCollection("node", 3)}">
      content inherited from page ${cmsfn:currentPage().handle}.html
   <cms:includeTemplate contentNodeName="node" />
   <cms:unloadPage />
 </c:if>
 

Parameters:
collectionName - paragraph collection name
minlevel - level at which we will stop also if no page is found
Returns:
true if a page has been found and loaded, false otherwise

firstPageWithNode

public static boolean firstPageWithNode(String nodeName,
                                        int minlevel)
Find and load the first parent page containing a named node. This function can be useful while building pages that should inherit a paragraph from parent pages. Loaded page must be unloaded using the <cms:unloadPage /> tag. Sample use:
 <c:if test="${cmsfn:firstPageWithNode("column", 3)}">
      content inherited from page ${cmsfn:currentPage().handle}.html
   <cms:contentNodeIterator contentNodeCollectionName="column">
     <cms:includeTemplate />
   </cms:contentNodeIterator>
   <cms:unloadPage />
 </c:if>
 

Parameters:
nodeName - paragraph name
minlevel - level at which we will stop also if no page is found
Returns:
true if a page has been found and loaded, false otherwise

nodeDataIterator

public static Collection nodeDataIterator(Content c,
                                          String collection)
Function to iterate over a node Data that has "checkbox" as control type, for example. See http://jira.magnolia-cms.com/browse/MAGNOLIA-1969



Copyright © 2003-2012 Magnolia International Ltd.. All Rights Reserved.