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

How to identify if URL contains editor.html in Sightly

Avatar

Avatar
Ignite 1
Level 1
saukaush
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back
Boost 1
View profile

Avatar
Ignite 1
Level 1
saukaush
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back
Boost 1
View profile
saukaush
Level 1

03-03-2021

I need to differentiate between below URLs in Sightly html.

http://localhost:4502/content/abc/xyz/test.html and

http://localhost:4502/editor.html/content/abc/xyz/test.html

 

How can I achieve the same? I tried using wcmmode.edit but it evaluates to true in both cases.

View Entire Topic

Avatar

Avatar
Ignite 3
Level 5
davidjgonzalezzzz
Level 5

Likes

69 likes

Total Posts

77 posts

Correct Reply

31 solutions
Top badges earned
Ignite 3
Affirm 25
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Ignite 3
Level 5
davidjgonzalezzzz
Level 5

Likes

69 likes

Total Posts

77 posts

Correct Reply

31 solutions
Top badges earned
Ignite 3
Affirm 25
Ignite 1
Give Back 5
Give Back 3
View profile
davidjgonzalezzzz
Level 5

04-03-2021

Your use case: "My component should be visible if URL contains editor.html and it should be hidden when editor.html is not present."

 

So you have a component that you want to display when the page is:

 

* Being Edited in Edit mode

* Being Previewed in Preview mode

* (Or any of the other views provided by Page Editor).


The only view you don't want this component to display is when it's outside of the Page Editor, which effectively means its in "Disabled" mode (youre just looking at the rendered web page and you cannot interact with it).

 

I wouldn't think about this as "is it in the page editor" but rather "what are the AEM author users *doing* in AEM that dictates when this component should show/hide".

 

So, it certainly sounds like you could do it by wcmmode == disabled

 


Remember, if youre trying to do stuff like window.location.href.indexOf('/editor.html') .. you would actually have to do window.top.location.href('/editor.html') .. as i mentioned in my previous post, the page with your components/code is being loaded in an IFRAME _BY_ the editor.