Sightly question: how to adapt a class with a path | Community
Skip to main content
New Participant
July 26, 2017
Solved

Sightly question: how to adapt a class with a path

  • July 26, 2017
  • 13 replies
  • 6741 views

In java code, I can do this:

Resource articleResource = resourceResolver.getResource("/somepath/for/article");
  Article article = articleResource.adaptTo(Article.class);

Can Sightly do the same? and how?

In AEM 6.3 with sling models.

Thanks.

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

Probably my answer would be yes. Try the below code

  Let me know if it doesn't work

Thanks

Veena

13 replies

VeenaVikraman
New Participant
July 26, 2017

I am not sure if that is possible, because as far as I could understand, data-sly-resource should refer a resource which will resolve using sling resolution principles . I am not sure if we can refer a page path and try to resolve it as a resource. May be feike_visser​ can help you in this

Thanks

Veena

BigT168Author
New Participant
July 26, 2017

That's what I am doing.

Probably I should ask if we can do this in the HTL code

data-sly-use or data-sly-resource?

Thanks for your response.

VeenaVikraman
VeenaVikramanAccepted solution
New Participant
July 26, 2017

Probably my answer would be yes. Try the below code

  Let me know if it doesn't work

Thanks

Veena