Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
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

Community Advisor

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

Community Advisor

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

Community Advisor

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

Community Advisor

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