Skip to main content
Level 2
Apr 3, 2017 10:28 PM UTC
Solved

Can we use a data-sly-use in an html or anyother way along with an asset?

I would like to execute a piece of code with all dam asset resources. How can I achieve this just like we do with a cq:Page? Any suggestions appreciated

 

Thanks 

Sanjay

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Ratna_Kumar
Ratna_KumarAccepted solution
Level 10
Apr 3, 2017 10:55 PM UTC

Hi,

I think you can do it for asset too. See this below example code snippet.

mimetype.html

<div data-sly-use.asset="com.day.cq.dam.api.Asset">
  <p>${asset.mimeType}</p>
</div>

The data-sly-use statement directs HTL to adapt the current Resource to an Asset and give it the local name asset. It then calls the getMimeType method of Asset using the HTL getter shorthand: asset.mimeType.

See this below Adobe documentation for more reference:

//https://docs.adobe.com/docs/en/htl/docs/use-api/java.html

Hope this helps!

~ Ratna.

3 replies

Ratna_Kumar
Ratna_KumarAccepted solution
Level 10
Apr 3, 2017 10:55 PM UTC

Hi,

I think you can do it for asset too. See this below example code snippet.

mimetype.html

<div data-sly-use.asset="com.day.cq.dam.api.Asset">
  <p>${asset.mimeType}</p>
</div>

The data-sly-use statement directs HTL to adapt the current Resource to an Asset and give it the local name asset. It then calls the getMimeType method of Asset using the HTL getter shorthand: asset.mimeType.

See this below Adobe documentation for more reference:

//https://docs.adobe.com/docs/en/htl/docs/use-api/java.html

Hope this helps!

~ Ratna.

Translate
smacdonald2008
Level 10
Apr 4, 2017 10:38 AM UTC

We have many articles that show use of assets and HTL. See http://scottsdigitalcommunity.blogspot.ca/2016/02/creating-aem-sightly-movie-component.html?m=0

Translate