Skip to content

Instantly share code, notes, and snippets.

@marcosblandim
Last active March 21, 2022 21:53
Show Gist options
  • Save marcosblandim/2a514a826989655d63ef88f7efb697b8 to your computer and use it in GitHub Desktop.
Save marcosblandim/2a514a826989655d63ef88f7efb697b8 to your computer and use it in GitHub Desktop.
LIFERAY: Get the Display Page's Asset inside a Freemarker
<#assign assetEntryLocalService = serviceLocator.findService("com.liferay.asset.kernel.service.AssetEntryLocalService")/>
<#if Request.INFO_ITEM_DETAILS??>
<#assign
info_item_reference = Request.INFO_ITEM_DETAILS.getInfoItemReference()
className = info_item_reference.getClassName()
classPK = info_item_reference.getClassPK()
asset = assetEntryLocalService.getEntry(className, classPK)
/>
${asset}
</#if>
* Works on Liferay 7.3+.
* Your Freemarker can be a Fragment, Widget Template, Web Content Template, etc; just make sure to use Freemarker's alternative square bracket syntax when inside a Fragment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment