Expand my Community achievements bar.

SOLVED

How to get suffix on click of sidekick button

Avatar

Level 4

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

3 Replies

Avatar

Level 10

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

Avatar

Level 4

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

Avatar

Correct answer by
Level 10

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