Skip to content

Instantly share code, notes, and snippets.

@gonzalezalo
Last active June 29, 2022 11:01
Show Gist options
  • Save gonzalezalo/548184d945546d72227bf9d64702a82e to your computer and use it in GitHub Desktop.
Save gonzalezalo/548184d945546d72227bf9d64702a82e to your computer and use it in GitHub Desktop.
Using Liferay WebContent Template from ADT - Liferay 7
<#-- Liferay info on templates: https://dev.liferay.com/discover/portal/-/knowledge_base/7-0/designing-uniform-content -->
<#-- There is more than just a way of doing this: -->
<#-- Option 1 -->
<#assign journalArticleLocalService = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService")>
<#if entries?has_content>
<#list entries as curEntry>
<#assign article = curEntry.getAssetRenderer().getArticle() />
<#assign model = objectUtil("com.liferay.portal.kernel.portlet.PortletRequestModel", renderRequest, renderResponse) />
${journalArticleLocalService.getArticleContent(article, article.getDDMTemplateKey(), "VIEW", locale, model, themeDisplay)}
</#list>
</#if>
<#-- Option 2 -->
<#-- Thanks to Kevin Boucher - https://stackoverflow.com/questions/45242941/how-can-i-access-a-web-content-structure-template-from-an-application-display-te/45248102#45248102 -->
<#if entries?has_content>
<#list entries as curEntry>
<#assign assetRenderer = curEntry.getAssetRenderer() />
<@liferay_ui["asset-display"]
assetEntry=curEntry
assetRenderer=assetRenderer
showExtraInfo=false />
</#list>
</#if>
@mrHiker
Copy link

mrHiker commented Nov 1, 2020

in liferay 7.3 it works this way:

<@liferay_asset["asset-display"]
assetEntry=curEntry
assetRenderer=assetRenderer
/>

liferay-ui:asset-display → liferay-asset:asset-display
Source:[(https://help.liferay.com/hc/en-us/articles/360017902892-Breaking-Changes)]

@d80wrk
Copy link

d80wrk commented May 6, 2021

Mr Hiker ... LIFESAVER !! Thank You.

In 7.0 I had : <@liferay_ui["asset-display"]
in 7.3 it didn't work. The documentation around this wasn't clear enough there from Liferay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment