Tuesday 18 October 2016

Liferay DXP/Liferay 7: embed web content in custom theme via ftl file

Want to add fix content via custom ftl template in Liferay 7/DXP.

Below is the sample code,

Code to embed web content in theme :

<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone") />
<#assign theme_groupID = htmlUtil.escape(theme_display.getCompanyGroupId()?string) />
<#assign VOID = freeMarkerPortletPreferences.setValue("groupId", '${group_id}') />
<#assign VOID = freeMarkerPortletPreferences.setValue("articleId", "yourarticleid") />
   
   
 
        <@liferay_portlet["runtime"]
        defaultPreferences="${freeMarkerPortletPreferences}"
        portletProviderAction=portletProviderAction.VIEW
        instanceId="footercontent"
        portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet" />
        ${freeMarkerPortletPreferences.reset()}
Make sure you provide the groupId of the site in which you have created web content.