Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Browser URL in Sightly

arvind
Level 4
Level 4

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
Theo_Pendle
Correct answer by
Community Advisor
Community Advisor

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
Varun_Shakya
Community Advisor
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].

arvind
Level 4
Level 4

@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

Varun_Shakya
Community Advisor
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>

Theo_Pendle
Correct answer by
Community Advisor
Community Advisor

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