Remove auto generated div tag around the components | Community
Skip to main content
New Participant
Sep 11, 2017 4:31 AM UTC
Solved

Remove auto generated div tag around the components

Hi all,

Need help to get rid of the auto generated extra div wrapper around the components ?  But this should be publisher mode only. Author mode need to be have that because of the editing panel.

Note that im using HTL (Not JSP) and i cannot edit global.js because i need that extra div wrapper on some component as well.

im using AEM 6.2 .

Kindly help on this matter.

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Feike_Visser1
Feike_Visser1Accepted solution
Employee
Sep 13, 2017 1:46 PM UTC

you can do data-sly-unwrap="${wcmmode.disabled}" then the div is removed is non edit mode.

so

<div ... data-sly-unwrap="${wcmmode.disabled}" ></div>

7 replies

rahulp76079001
Level 2
Jul 26, 2021 6:38 AM UTC

create cq:htmlTag node as nt:unstructured,

create property cq:tagName and leave it blank.

This seems perfect solution for removing default wrapper from a component.

This node can be used to set any class and to change the wrapper element.

Translate
ajinkayk6258253
Level 3
Aug 28, 2019 7:39 AM UTC

can anybody provide solution for jsp component

Translate
Level 2
Jun 4, 2018 9:37 PM UTC

Could you please post an example for this one.

Translate
susheel
Level 5
Sep 14, 2017 3:51 AM UTC

you can use cq:htmlTag node in your component to generate your custom div with custom class.

cq:tagName : Here you can define the div or section or whatever tag you need.

I observed that if we don't provide cq:tagName the extra div itself is not getting generated (tested in 6.1 SP2)

So may be you can use this way.

Translate
Feike_Visser1
Feike_Visser1Accepted solution
Employee
Sep 13, 2017 1:46 PM UTC

you can do data-sly-unwrap="${wcmmode.disabled}" then the div is removed is non edit mode.

so

<div ... data-sly-unwrap="${wcmmode.disabled}" ></div>

Translate
AnkurAhlawat-1
Level 6
Sep 13, 2017 10:37 AM UTC

Have you tried below property

  • cq:noDecoration {boolean} : This property can be added to a component and a true value forces AEM not to generate any wrapper elements over the component.

You can apply this to specific components for which you dont want wraper divs. For more info visit Decoration Tag

Translate
kautuk_sahni
Employee
Sep 13, 2017 9:54 AM UTC

Try this:-

     <sly data-sly-resource="${'foo' @ decorationTagName=(wcmmode.<Mode>? '':'div') , resourceType='my/resource/type}"/>

Feike Visser What do you think here?

~kauutk

Translate
Kautuk Sahni