Browser URL in Sightly

arvind

02-09-2020

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.

Accepted Solutions (1)

Accepted Solutions (1)

Theo_Pendle

MVP

03-09-2020

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

 

Answers (2)

Answers (2)

Varun_Shakya

MVP

02-09-2020

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

arvind

02-09-2020

@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