WCMmode in conditional comments | Community
Skip to main content
New Participant
October 4, 2017
Solved

WCMmode in conditional comments

  • October 4, 2017
  • 9 replies
  • 5941 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Feike_Visser1

do something like this

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

your stuff

</sly>

9 replies

Prince_Shivhare
New Participant
October 4, 2017

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

Feike_Visser1
Feike_Visser1Accepted solution
Employee
October 4, 2017

do something like this

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

your stuff

</sly>

viveksachdeva
New Participant
October 4, 2017

HTL counterpart of this would have same impact I believe:

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

New Participant
October 4, 2017

I am using AEM 6.3.

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

viveksachdeva
New Participant
October 4, 2017

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]-->

    <%}%>

New Participant
October 4, 2017

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

viveksachdeva
New Participant
October 4, 2017

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

New Participant
October 4, 2017

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

viveksachdeva
New Participant
October 4, 2017

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