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

Browser URL in Sightly

Avatar

Level 6

Dear Team,

 

Is there any way we can print exact browser URL in Sightly HTML?

 

e.g.

1) if Page url is http://localhost:4502/editor.html/content/home.html

 

It should print exact same i.e.  http://localhost:4502/editor.html/content/home.html

 

2) If Page url is http://localhost:4502/content/home.html

 

It should print exactly same i,e http://localhost:4502/content/home.html.

 

Note: I tried with  ${request.requestURL.toString} but in both the cases it prints only 

 

http://localhost:4502/content/home.html. . It ignores editor.html.

 

Thank you in advance.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi @arvind,

This is normal for a typical AEM Author instance installation. The reason is that the WCMMODE is EDIT by default on Author instances, which is mentioned in the documentation here: https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/co...

In order to simulate a Publisher instance, you must add ?wcmmode=disabled to the URL, regardless of whether /editor.html is present in the URL or not (this is what the View as Published option does).

I demonstrate this in the GIF below:

Peek 2020-09-03 21-17.gif

 

View solution in original post

4 Replies

Avatar

Community Advisor

If it is not utmost important to use sightly particularly, you can leverage JS(

window.location.href 

) and jquery to get the URL and then append it html tag where you want it.

If you want to use sightly only then I guess you are able to get the full URL except "editor.html".

In this case you can form your URL add "editor.html" in URL if the user is in Edit mode [wcmmode.edit].

Avatar

Level 6

@Varun_Shakya , Thank you for your reply.

 

Actually my req is to add some class in a div only when we are in edit mode i.e. when url contains editor.html.

 

I already tried wcmmode.edit but unfortunately it always gives me true whether I hit  http://localhost:4502/editor.html/content/home.html  or  http://localhost:4502/content/home.html.

 

Regards,

AP

Avatar

Community Advisor

refer this

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-add-the-author-edit...

 

Check for Arun's comment

 

<sly data-sly-test.editor="${wcmmode.edit || wcmmode.design}"></sly>

<div id="mydivid" class="${editor?'abcd xyz myclass':'abcd xyz'}">

     ........

</div>

Avatar

Correct answer by
Level 10

Hi @arvind,

This is normal for a typical AEM Author instance installation. The reason is that the WCMMODE is EDIT by default on Author instances, which is mentioned in the documentation here: https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/co...

In order to simulate a Publisher instance, you must add ?wcmmode=disabled to the URL, regardless of whether /editor.html is present in the URL or not (this is what the View as Published option does).

I demonstrate this in the GIF below:

Peek 2020-09-03 21-17.gif