Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!
SOLVED

Remove auto generated divs while including component

Avatar

Level 4

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

1 Accepted Solution

Avatar

Correct answer by
Level 8

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> <% } %>

View solution in original post

7 Replies

Avatar

Level 4

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

Avatar

Level 8

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.

Avatar

Level 4

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);                            
}

Avatar

Level 4

Sorry, that approach is not working.

Avatar

Correct answer by
Level 8

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> <% } %>