Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save d80wrk/67c4cbf1a75c9e629b621836831e9dea to your computer and use it in GitHub Desktop.
Save d80wrk/67c4cbf1a75c9e629b621836831e9dea 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment