How to access Gloabal objects in HTL

Avatar

Avatar

rohitn62196663

Avatar

rohitn62196663

rohitn62196663

12-10-2016

I have gone through the documentation in below url about Global objects in HTL:

https://docs.adobe.com/docs/en/htl/docs/global-objects.html.

 

I need to change the below existing code in JSP to Sightly(HTL):

<%

 if (WCMMode.fromRequest(request) == WCMMode.EDIT){
            %><img src="/libs/cq/ui/resources/0.gif" class="cq-carousel-placeholder" alt=""><%
        }

%>

I want to access the wcmmode and the request object directly in sightly without using the Java class. However I am facing issues in doing that. Could someone provide me the way(syntax) to access the objects directly in HTL ?

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

12-10-2016

Check the HTL spec here: 

https://github.com/Adobe-Marketing-Cloud/htl-spec/blob/master/SPECIFICATION.md

For example: 

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

Hope this helps.... 

Answers (2)

Answers (2)

Avatar

Avatar

rohitn62196663

Avatar

rohitn62196663

rohitn62196663

12-10-2016

Thanks a lot it worked. I was using the upper case thats why it didn't work.

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

12-10-2016

<img data-sly-test="${wcmmode.edit}" src="/libs/cq/ui/resources/0.gif" class="cq-carousel-placeholder" alt="">