How to get suffix on click of sidekick button | Community
Skip to main content
Level 4
October 16, 2015
Solved

How to get suffix on click of sidekick button

  • October 16, 2015
  • 3 replies
  • 939 views

Hi All,

I am trying to add custom action to sidekick, for which I want to get the url suffix. Any idea how this can be done.

Also will this work when we have some etc mapping for our urls?

Thanks!

Shehjad

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by edubey

Its all playing with JS. You can manipulated alot with JS, if you are hitting at right area.

1st Part ...

CQ.WCM.getPagePath(); will give you current page path

Get the last part the page like this...

x = "/a/b/c/d";
y = x.substring(x.lastIndexOf("/");

y will be "/b" which in you case will be item code.

2nd part

You can sent a GET request to /etc/map/http.1.json to get json response.

Thats it...

Pass the full path which you want to give as a hyperlink to CQ.shared.Util.open(url);

Refer to the above shared article for help.....its talks about all this.......

3 replies

edubey
Level 10
October 16, 2015

Hi Shehjad,

Here is the similar use case implemented, It adds a button and onclick it opens a url.

http://adobeaemclub.com/customize-aem-sidekick-add-useful-feature/

Can you tell me, which suffix you are trying to get

Level 4
October 16, 2015

Hi Praveen,

My actual URL is like /content/site/en/products.html/item-12   . Where item-12 is code of my product.

But we also want to apply etc mapping on this and thus it might render on browser like /products.item-12.html. I want to write a code to get my product code on click of button in such a way that it works both with mapping and without mapping.

Thanks!

Shehjad

edubey
edubeyAccepted solution
Level 10
October 16, 2015

Its all playing with JS. You can manipulated alot with JS, if you are hitting at right area.

1st Part ...

CQ.WCM.getPagePath(); will give you current page path

Get the last part the page like this...

x = "/a/b/c/d";
y = x.substring(x.lastIndexOf("/");

y will be "/b" which in you case will be item code.

2nd part

You can sent a GET request to /etc/map/http.1.json to get json response.

Thats it...

Pass the full path which you want to give as a hyperlink to CQ.shared.Util.open(url);

Refer to the above shared article for help.....its talks about all this.......