RE: Web content templates: Make Document Library URL relative

David H Nebinger, modified 1 Year ago. New Member Posts: 3 Join Date: 11/1/22 Recent Posts

Hi,

our customer is using Liferay DXP 2023.q4.4 and has an ftl template, which renders an image using component.documentUpload.getData()

They we found out that the "getData()" method is served by Java method com.liferay.portlet.documentlibrary.util.getPreviewURL

The generated URL is absolute, that means it starts with https://domain.com/ 

The issue is now, that, if caching is enabled for the web content template, the URL will be cached with full domain name. Since the Liferay instance serves two domains - one for internal use within the customer's network, allowing access to the Liferay admin UI, and one for access from the public internet - wrong URL names are being delivered. This way, the html that is delivered to public users contains URLs that point into the internal network, and cannot be resolved.

In order to fix this situation and keep caching enabled, I am asking you to:

Please make it possible to easily retrieve relative URLs for document library assets from within .ftl templates

As an alternative (which is not preferred by the customer), I could imagine that adding the requested host name to the cache key would do the job.

Best,

Tobias

thumbnail
Jamie Sammons, modified 1 Year ago. Expert Posts: 367 Join Date: 9/5/14 Recent Posts

Feature Request Created: https://liferay.atlassian.net/browse/LPD-26324