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

links transformation

sreedobe
Level 4
Level 4

Hi All,

 

I got following use case and looking for options as well clarity on sling rewrite transformer factory, transformer.

 

mobile app will access AEM site urls with a query parameter "mobile=true" and header, footer needs to be hidden.

 

options:

1. append query param "mobile=true" to all anchor elements hrefs

2. use sling rewrite transformer factory, transformer to transform all anchor urls.

3. store a cookie on first request and if cookie exists or url has query param - hide header, footer

 

Question: If I go in transformer route, does it transform only content urls that exists or does it transform all internal, external urls ?

 

thanks.

Sri

1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Hi,

Why don't you use css to hide or javascript to hide/delete header/footer on page load. It will be easy, maintainable and client side.

View solution in original post

8 Replies
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Hi,

Why don't you use css to hide or javascript to hide/delete header/footer on page load. It will be easy, maintainable and client side.

View solution in original post

sreedobe
Level 4
Level 4

@Arun_Patidar on first request from mobile app , I can do that. once mobile app got response from aem page - which is having lot of links to articles, other aem site pages. If user clicks on any of the link that should also not have header and footer : means somehow I need to have a handle to know, to display mobile view without header and footer, all the time, serving different aem pages. As mobile app first request , mobile app could append "mobile" param but after that all other requests are internal to aem site and need to hide header, footer on click of going to any other aem pages.

Arun_Patidar
Community Advisor
Community Advisor
Generally this kind of request handles using selector and aem response based on selector where you don't include haeder and footer in mobile.html file. Add selector to all internal links which start with /content/yourproj also using linktransformer
sreedobe
Level 4
Level 4

@Arun_Patidar thanks for usage of "selector" idea, I can try that. One question though (which I asked in original question) : Does Transformer transforms only /content links ? there are absolute urls which are external sites as well as organization other aem sites, regular websites.

Arun_Patidar
Community Advisor
Community Advisor
No, you can parse any kind of links and update. I have code example in case you need.
sreedobe
Level 4
Level 4

@Arun_Patidar example helps and appreciated. But, I wanted only /content links to have selector. As I do not want to control other than aem content pages.

Arun_Patidar
Community Advisor
Community Advisor

https://github.com/arunpatidar02/aem63app-repo/blob/master/java/CustomLinkChecker.java  is the sample code example which parse only internal links , you can restrict execution of this link rewriter for links from rewriter config