Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

data-sly-resource rendering a different htl template?

Avatar

Level 7

Hi

I would like to use data-sly-resource to render a HTL that is somewhat different then the existing one.

I tried using selectors='overview'

data-sly-resource="${event.resource @ resourceType='xxx/components/content/eventTeaser', selectors='overview'}">

and created a copy of eventTeaser called eventTeaser.overview.html.

The problem is that the new HTL template eventTeaser.overview.html is not called but instead the eventTeser.html is called.

 

Of course eventTeaser.overview.html exists and it is in the same directory as eventTeaser.html is.

 

What am I doing wrong here and what would be a good solution for this?

5 Replies

Avatar

Community Advisor

@anasustic 

data-sly-resource="${event.resource @ resourceType='xxx/components/content/eventTeaser',appendPath='eventTeaser.html' addSelectors='overview'}">

I guess, you can try something like this. 

Avatar

Level 7

Hi,

thanks for writing.

I tried it exactly like your wrote but it is again using the eventTeaser.html and not the eventTeaser.overview.html.

Avatar

Community Advisor

@anasustic In that case you could try to create  "overview.html" instead of eventTeaser.overview.html and try this-

data-sly-resource="${event.resource @ resourceType='xxx/components/content/eventTeaser', addSelectors='overview'}">

  

Avatar

Employee Advisor

Hi @anasustic ,

 

In this case, you just need to create "overview.html".

 

This "eventTeaser.overview.html" would have worked if there was a folder "eventTeaser" and overview.html inside it.

 

Check your Sling's recent request to trace the request and get more information.

http://localhost:4502/system/console/requests 

 

Also, check this cheatsheet for sling resolution

https://experienceleague.adobe.com/docs/experience-manager-65/developing/platform/sling-cheatsheet.h... 

 

Hope that helps!

Regards,

Nitesh

Avatar

Level 7

Thank you so very much @nitesh_kumar for your answer and your suggestion about the tracing that the cheatsheet. Super valuable resources