Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

WCMmode in conditional comments

Avatar

Level 4

Hi All,

I am using conditional comment to check browser version.

Is there a way to check wcmmode of the instance in conditional comments?

I want to show the message in author/edit mode.

Following is my piece of code in component:

<!--[if lt IE 9]> 

  <div class="upgrade-browser-banner" role="alert">

         <h4>upgrade your browser message</h4> 

  </div>

<![endif]-->

i tried the following but it's not working:

<!--[if (lt IE 9) | (WCMmode.edit) ]>

Please Help.

1 Accepted Solution

Avatar

Correct answer by
Employee

do something like this

<sly data-sly-test="${wcmmode.edit}">

your stuff

</sly>

View solution in original post

9 Replies

Avatar

Level 7

I dont think you can check it inside the conditional comment. The check should work if you do it in body of condition...

Avatar

Level 4

I want it to be available in author mode to be edited even if the browser satisfies the condition in 'if' block.

Avatar

Level 7

Ok. understood... then one thing you can probably do is to have this conditional comment inside WCMmode.edit.. i mean just the if line and end-if line

Avatar

Level 4

I tried that but if the browser is above IE 9, its not allowing authors to edit the component.

Avatar

Level 7

I dont have IE browser but I tested it on non IE and it works...

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

<!--[if lt IE 9]>

<%}%>

  <div class="upgrade-browser-banner" role="alert">

        <cq:include path="alertMessage" resourceType="foundation/components/text"/>

  </div>

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

<![endif]-->

    <%}%>

Avatar

Level 4

I am using AEM 6.3.

As per client standards, we cannot use scriplets in html files.

Avatar

Level 7

HTL counterpart of this would have same impact I believe:

<div data-sly-test="${wcmmode.edit}">

Avatar

Correct answer by
Employee

do something like this

<sly data-sly-test="${wcmmode.edit}">

your stuff

</sly>

Avatar

Community Advisor

Hi,

As fieke suggest please use data-sly-test to check the different mode.

please check this link:

htl-spec/SPECIFICATION.md at master · Adobe-Marketing-Cloud/htl-spec · GitHub

Regards,

Prince