Customizing asset publisher to open links in a new window

Amos Fong, modified 6 Years ago. Junior Member Posts: 39 Join Date: 8/15/17 Recent Posts
One of the departments I am building a portal for wants specific documents listed on various pages.  This is easily done using the asset publisher and tags.  However, they want the document to open in a new windows when clicked, instead of opening in context or in another Liferay page.  They want the physical document - say a PDF - to open in a new window.

I haven't found a way to do that using the asset publisher configuration itself.  I assume this can be done using some sort of custom display template but I haven't had any success in finding any examples I can use.

Does anyone know the best way to do this and if so, can you please point me to some code to use as a basis?

Thank you!
​​​​​​​
thumbnail
Mohammed yasin, modified 6 Years ago. Liferay Master Posts: 593 Join Date: 8/8/14 Recent Posts
Hi,
 You can use the below ftl code for rendering assets and preview url in new tab , In case you need in new window you can use url to open new window in javascript
[code]<#if entries?has_content> 
         <#list entries as curEntry>
    <a href=" ${curEntry.getAssetRenderer().getURLImagePreview(renderRequest)}" target="_blank">${curEntry.getTitle(locale)}</a>
       <br>
    
<!--#list--> 
<!--#if-->