Expand my Community achievements bar.

SOLVED

anchor tag href value shortening inconsistently

Avatar

Former Community Member

Hi,

 

I am currently using AEM 6.5.13. I am trying to render some links using "href" in anchor <a> tag.

 

Sample code:

 <a href="${slingObject.link}"/>

 

This link has 2 values coming from backend,

/content/marketA/index/pageA.html 

/content/marketB/index/pageB.html

Now the href value comes in this format in BROWSER through dispatcher URL, which is clearly inconsistent

In case A,  <a href="/content/marketA/index/pageA.html"/>

while in case B, <a href="pageB.html"/>

 

These markup are part of DOM loading on some other page hierarchy, say mysite.com which corresponds to /content path.

 

When I click on the links, the URL it tries to fetch is,

Case A: www.mysite.com/content/marketA/index/pageA.html response 200 and page renders

Case B: www.mysite.com/content/pageB.html response 404 and page does not renders.

 

In my opinion, the behavior should be consistent. I have tried following:

1. Check how it is being rendered in Author and Publish: Full path shows up in the DOM

2. Check what has been cached in the dispatcher: Full path again getting cached.

 

What could be the issue ?

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 6

It seems you are having issue with Map.

 You can check following..

1. Before sending the link from backend  use resourceResolver.map(link);

2. Check dispatcher rule because from dispatcher we generally hide /content/sitename

 

if you use resourceResolver.map(link) i think your problem will be solved.

View solution in original post

3 Replies

Avatar

Correct answer by
Level 6

It seems you are having issue with Map.

 You can check following..

1. Before sending the link from backend  use resourceResolver.map(link);

2. Check dispatcher rule because from dispatcher we generally hide /content/sitename

 

if you use resourceResolver.map(link) i think your problem will be solved.

Avatar

Community Advisor

Hi @Deleted Account ,

 

Please check if you have 'URL mapping' added to 'Apache Sling Resource Resolver Factory' or custom link rewriter added to your project. Please use below videos for reference-

 

https://www.youtube.com/watch?v=zcKwRTZ78_Y&list=PLzwWOJSdKWBf7zLga8P7-ARxFQRwGGd94&index=29

 

https://www.youtube.com/watch?v=0fM2vUEj2bA&list=PLzwWOJSdKWBf7zLga8P7-ARxFQRwGGd94&index=30

 

Thanks,

Ritesh Mittal

Avatar

Community Advisor

Are you seeing this issue on author, publisher or dispatcher or on all 3.

on author and publisher it should start with /content/sitename/locale/page.html and on dispatcher it should be without /content/sitename