Issue Using sling:alias to get url translated | Community
Skip to main content
Level 3
March 1, 2022

Issue Using sling:alias to get url translated

  • March 1, 2022
  • 1 reply
  • 1801 views

Hello Community,

 

I have following situation 

 

/content/xyz/en/application/test.html

|                                           sling:alias = mytesten

|

|

/content/xyz/fr/application/test.html

                                          sling:alias = mytestfr

 

with these alias set i am able to access /content/xyz/fr/application/mytestfr.html

 

I also have alias for application under fr node set to myapplicationfr

Hence i am able to access /content/xyz/fr/myapplicationfr/mytestfr.html as well.

 

However, when selecting the page using pagefield component  in the dialog which would show the pages to select, the url which gets linked is only /content/xyz/fr/application/mytestfr.html instead of /content/xyz/fr/myapplicationfr/mytestfr.html

 

Has any one faced this situation of not able to resolve the sling:alias for parent pages in the path for a CTA?

 

Thanks

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

1 reply

Siva_Sogalapalli
Community Advisor
Community Advisor
March 2, 2022

Hi @user70744 

 

The property sling:alias may be set on any resource to indicate an alias name for the resource. For example the resource /content/visitors may have the sling:alias property set to besucher allowing the resource to be addressed in an URL as /content/besucher as well as the original path /content/visitors.

 

So you will not able to directly browse alias path using pathfield from dialog, you need to explicitly add alias path the way you want to have it for CTA. 

 

For more info:
https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html 

https://www.javacodexamples.com/examples/slingalias-vs-vanityurl-in-aem 

 

Hope this helps.

 

 

user70744Author
Level 3
March 2, 2022

Thanks @siva_sogalapalli 

I do have sling:alias in the path  /content/xyz/fr/application/test.html

i.e

test -> mytestfr as sling:alias

application -> myapplicationfr as sling:alias

 

However pagefield component is able to resolve only the last path i.e test for alias and not for application

 

Any views or you have come across this situation?

 

Thanks

Arun