Issue
When using an Asset Publisher to display a list of assets, clicking on an asset correctly navigates to a detail page. However, when clicking the 'back' arrow provided by the Asset Publisher on the detail page, it does not return to the previous list page. Instead, it reloads the detail page, which appears blank or without any content selected.
This issue typically occurs when a custom Application Display Template (ADT) is used to manually generate the URLs for the asset detail links.
Environment
- Liferay DXP
Resolution
The problem is caused by manually constructing the asset's URL within the custom ADT. This manual URL is missing the necessary redirect parameter that the Asset Publisher's back button relies on to function correctly.
To resolve this, follow the recommended approach of using Liferay's Display Page feature and the Asset Publisher's API within the ADT:
-
Configure a Display Page:
- In your site, navigate to Site Builder → Pages.
- Go to the configuration of the page intended to display the full content (e.g., a page named 'News Detail').
- Under the 'Advanced' tab, set this page as the Display Page for the relevant asset type (e.g., a 'News' structure).
-
Set the Default Asset Publisher:
- On the same detail page, configure the Asset Publisher portlet.
- In the Display Settings tab, check the box for Set as the Default Asset Publisher for This Page.
-
Update the Custom ADT:
- Edit the ADT used for the asset list view.
- Instead of manually building the URL, use the
assetPublisherHelper.getAssetViewURL(...)API. This helper method automatically generates the correct URL, including theredirectparameter. - Example snippet for an ADT:
<#assign assetEntry = assetRenderer.getAssetEntry() /> <#assign viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, assetEntry) /> <a href="${viewURL}">${assetEntry.getTitle(locale)}</a>
By implementing these changes, the back button on the asset detail page will correctly redirect the user to the previous asset list page.
Additional Information