Remove auto generated divs while including component | Community
Skip to main content
New Participant
January 25, 2016
Solved

Remove auto generated divs while including component

  • January 25, 2016
  • 7 replies
  • 1991 views

Hi,

I am including a component like this:

 

<c:forEach begin="0" end="${selectList-1}" varStatus="loopSubmenu"> <sling:include path="submenu_${loopSubmenu.index}" resourceType="aemdevcenter/components/content/global-header/submenu" /> </c:forEach>

and to get rid of the auto generated divs I have included the below code in my global.jsp

<% if (WCMMode.fromRequest(request) != WCMMode.EDIT && WCMMode.fromRequest(request) != WCMMode.DESIGN && WCMMode.fromRequest(request) != WCMMode.DISABLED && WCMMode.fromRequest(request) != WCMMode.PREVIEW) { IncludeOptions.getOptions(request, true).forceSameContext(Boolean.TRUE); } %>

But I am still not able to get rid of the auto generated divs and this is messing with the styles. Any ideas ?

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by leeasling

You probably just have it wrong.

<% if (WCMMode.fromRequest(request) == WCMMode.EDIT || WCMMode.fromRequest(request) == WCMMode.DESIGN) { %> <c:forEach begin="0" end="${selectList-1}" varStatus="loopSubmenu"> <sling:include path="submenu_${loopSubmenu.index}" resourceType="aemdevcenter/components/content/global-header/submenu" /> </c:forEach> <% } else { %> <c:forEach begin="0" end="${selectList-1}" varStatus="loopSubmenu"> <sling:include cq:noDecoration="true" path="submenu_${loopSubmenu.index}" resourceType="aemdevcenter/components/content/global-header/submenu" /> </c:forEach> <% } %>

7 replies

leeaslingAccepted solution
New Participant
January 26, 2016

You probably just have it wrong.

<% if (WCMMode.fromRequest(request) == WCMMode.EDIT || WCMMode.fromRequest(request) == WCMMode.DESIGN) { %> <c:forEach begin="0" end="${selectList-1}" varStatus="loopSubmenu"> <sling:include path="submenu_${loopSubmenu.index}" resourceType="aemdevcenter/components/content/global-header/submenu" /> </c:forEach> <% } else { %> <c:forEach begin="0" end="${selectList-1}" varStatus="loopSubmenu"> <sling:include cq:noDecoration="true" path="submenu_${loopSubmenu.index}" resourceType="aemdevcenter/components/content/global-header/submenu" /> </c:forEach> <% } %>
New Participant
January 26, 2016

Sorry, that approach is not working.

Lokesh_Shivalingaiah
New Participant
January 26, 2016

Yes ! You can also refer [1] for the actual statement

[1] http://adobeaemclub.com/how-to-remove-default-div-generated-by-cq5-aem-for-component/

New Participant
January 26, 2016

So do you want me to include 

 

<sling:include path="submenu_${loopSubmenu.index}" resourceType="aemdevcenter/components/content/global-header/submenu" />

 

Inside the if statement 

if (WCMMode.fromRequest(request) != WCMMode.EDIT && WCMMode.fromRequest(request) != WCMMode.DESIGN && WCMMode.fromRequest(request) != WCMMode.DISABLED && WCMMode.fromRequest(request) != WCMMode.PREVIEW) {
    IncludeOptions.getOptions(request, true).forceSameContext(Boolean.TRUE);                            
}

New Participant
January 25, 2016

Wrap the include in an if statement.  If you're in edit or design mode, do not include the "cq:noDecoration" or "cq:cellName(empty)" tags, otherwise do.

New Participant
January 25, 2016

When I try to use either cq:noDecoration or cq:cellName(empty) I lose the ability to author the component. 

smacdonald2008
New Participant
January 25, 2016