Tuesday, 13 February 2018

Embed Webcontent using Title using Freemarker template in liferay dxp

<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone") />
<#assign theme_groupID = htmlUtil.escape(theme_display.getCompanyGroupId()?string) />
<#assign VOID = freeMarkerPortletPreferences.setValue("groupId", '${group_id}') />
<#assign journalArticleLocalService =          serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalService") />
<#assign footercontentarticle = journalArticleLocalService.getArticleByUrlTitle(group_id,"footercontent")/>
<#assign VOID = freeMarkerPortletPreferences.setValue("articleId", footercontentarticle.getArticleId()) />

        <@liferay_portlet["runtime"]
        defaultPreferences="${freeMarkerPortletPreferences}"
        portletProviderAction=portletProviderAction.VIEW
        instanceId="footercontent"
        portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet" />
        ${freeMarkerPortletPreferences.reset()}


Setting ===>
  For embedding WebContent in Liferay 7, first of all, you have to enable serviceLocator in Control Panel -> Configuration -> System Settings -> Foundation -> FreeMarker Engine -> Restricted Variables. There you can remove serviceLocator


References 
1> https://stackoverflow.com/questions/38227528/how-to-embed-webcontent-in-freemarker-liferay-7-theme

No comments:

Post a Comment