WCMmode in conditional comments | Community
Skip to main content
Level 4
Oct 4, 2017 7:11 AM UTC
Solved

WCMmode in conditional comments

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.
Feike_Visser1
Feike_Visser1Accepted solution
Employee
Oct 4, 2017 5:14 PM UTC

do something like this

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

your stuff

</sly>

9 replies

Prince_Shivhare
New Participant
Oct 4, 2017 5:42 PM UTC

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

Translate
Feike_Visser1
Feike_Visser1Accepted solution
Employee
Oct 4, 2017 5:14 PM UTC

do something like this

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

your stuff

</sly>

Translate
viveksachdeva
New Participant
Oct 4, 2017 10:26 AM UTC

HTL counterpart of this would have same impact I believe:

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

Translate
Level 4
Oct 4, 2017 10:24 AM UTC

I am using AEM 6.3.

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

Translate
viveksachdeva
New Participant
Oct 4, 2017 10:16 AM UTC

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

    <%}%>

Translate
Level 4
Oct 4, 2017 9:51 AM UTC

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

Translate
viveksachdeva
New Participant
Oct 4, 2017 8:48 AM UTC

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

Translate
Level 4
Oct 4, 2017 8:35 AM UTC

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

Translate
viveksachdeva
New Participant
Oct 4, 2017 7:24 AM UTC

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

Translate