Pravin
Pravin

Reputation: 11

How to use cq:noDecorator property in cq5 , can the default 'div' tag be changed to other block tags

I need to remove decorator 'div' tags added around components by CQ5 for few select components. They can be part of the mark up in author mode, but it should not be present in the final mark up on publish.

Upvotes: 1

Views: 3242

Answers (3)

Sharath Madappa
Sharath Madappa

Reputation: 3402

To change the default div tags to something else , use cq:htmlTag nodes in your components. This lets you modify the tag , classes and id associated with the decorator tag.

  • Create cq:htmlTag node [primaryType:nt:unstructured] under your component.
  • Add cq:tagName property [type:String] with the tag to be used as value.
  • Add class property [type:String] with class(es) to be added to the enclosing tag **
  • Add id property [type:String] with id to be added to the enclosing tag

    ** CQ will add an extra class of its own.

Source : http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2013/04/modify_the_auto-generateddivs.html

Upvotes: 2

Yogesh Upadhyay
Yogesh Upadhyay

Reputation: 16

You can also use this

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

Upvotes: 0

Thomas
Thomas

Reputation: 7108

You can wrap them in an if statement. Using JSTL:

<%
if (WCMMode.fromRequest(request) == WCMMode.EDIT) {
%>
<div>
<%
}
%>

Of course you shouln't use java code in the JSP directly, but rather put it in a request variable and use JSTL:

<c:if test="${isEditMode}">
<div>
</c:if>

If you want to get rid of the automatic generated divs, you would need to combine this with the noDecorator property and add the edit dialog script by other means within your optional divs.

Upvotes: 0

Related Questions