Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Current Page in Sling dynamic include

Avatar

Level 2

Hello , I am using the sling dynamic include for some of the resources, it's working in expected way. My question is can we get the current page  in sling dynamically included component  ?

 

Thanks in advance !!

6 Replies

Avatar

Community Advisor

@margaritageg 

Have you checked this - 

${request.requestURL.toString}

Or

<sly data-sly-test.scheme="${request.scheme}"/>
<sly data-sly-test.servername="${request.serverName}"/>
<sly data-sly-test.serverport="${request.serverPort}"/>
<sly data-sly-test.val="${request.requestURI}"/>
${scheme}://${servername}:${serverport}${val}

 Ref - Apache Sling :: Apache Sling Dynamic Include

Avatar

Community Advisor

Hi @margaritageg ,

Can you try checking with currentPage object?

Avatar

Administrator

@margaritageg Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 2

I didn't get the answer. I had trouble using experience fragments directly as dynamic includes. So, I tried something else. Instead of using the whole experience fragment, I just took out the part I needed for the dynamic include. Now, I can control things better and get the results I want