Skip to content

WCMMode Helpers

David Steele edited this page Aug 25, 2014 · 5 revisions

ironsites ironsites

AEM better

WCMMode Helpers

WCMMode Helpers - wcmmode & ismode

ironsites provides a Map JSP variable and PageContext object called "ismode" which contains a boolean value comparing a key corresponding to each WCMMode and an equals comparison against the current WCMMode. Usage is predicated on the taglib declaration found in /apps/ironsites/common/global.jsp. Additionally, the WCMMode object is also exposed. The below expresses how much boilerplate is removed by this.

<% if (!WCMMode.EDIT.equals(WCMMode.fromRequest(sling.getRequest()))) { %> ... <% } %>

feels batman

<c:if test="${'EDIT' ne wcmmode}">...<c:if>

feels betterman

<c:if test="${not ismode.edit}">...<c:if>

feels goodman

Moreover, you can force a wcmmode if it is valid. This should scale to some of the newer modes going forward.

<isw:wcmmode mode="disabled">Disabled mode!</isw:wcmmode>
Clone this wiki locally