Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Customizing asset publisher to open links in a new window
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!
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!
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
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-->
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™