Sunday, January 31, 2016

AEM / CQ5 Tips : Avoiding AEM generated wrapper div around the components in preview and publish mode


To implement it, the following changes need to be done in the application.

1. Add the following scriptlet in project specific global.jsp

<%@page session="false" import="com.day.cq.wcm.api.components.IncludeOptions, com.day.cq.wcm.api.WCMMode" %>
<% if (WCMMode.fromRequest(request) != WCMMode.EDIT && WCMMode.fromRequest(request) != WCMMode.DESIGN) { IncludeOptions options = IncludeOptions.getOptions(request, true);
options.setDecorationTagName("");
} %>

2. Create a new parsys component for the project by extending /libs/foundation/components/parsys. Override parsys.jsp by copying content in parsys.jsp in /libs/foundation/components/parsys
and replacing <%@include file="/libs/foundation/global.jsp"%> with <%@include file="/apps/my_project/foundation/global.jsp"%>

3. Replace /libs/foundation/components/parsys with /apps/my_project/foundation/global.jsp in the entire application (in jsps, where parsys is included and
custom parsys components with property sling:resourceSuperType as foundation/components/parsys )

No comments: