Your most unhappy customers are your greatest source of learning.

Embed web content in theme- Liferay6.X.X

December 12, 2011

Hello Liferay folks,

I know that many time you will have this requirement that you need to integrate web content into Liferay theme.
So here is the code which can help you to integration :

Please follow the below steps :

1) Create theme in liferay
2) create liferay-look-and-feel.xml and put below code:
     <?xml version="1.0"?>
<!DOCTYPE look-and-feel PUBLIC "-//Liferay//DTD Look and Feel 5.0.0//EN" "">

        <company-includes />
        <company-excludes />
    <theme id="drupal-garland" name="drupal-garland">
          <setting key="portlet-setup-show-borders-default" value="false" />
          <setting key="header-article-id" value="header-article-id" />
          <setting key="sidebar-article-id" value="sidebar-article-id" />
          <setting key="footer-article-id" value="footer-article-id" />

3) Now put the below code in .vm file where you want to show that web content.
    #set ($portletSetupShowBordersDefault = $theme_settings.getProperty("portlet-setup-show-borders-default"))

#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))

#set ($headerArticleId = $theme_settings.getProperty("header-article-id"))
#set ($journalArticleContentObject = $journalArticleLocalService.getArticleByUrlTitle( $theme_display.getCompanyGroupId(), $headerArticleId))
#set ($templateId = $journalArticleContentObject.getTemplateId())
#set ($headerContent = $journalContentUtil.getContent( $theme_display.getCompanyGroupId(), $journalArticleContentObject.getArticleId(), $templateId, "$locale", $theme_display))

<div id="header">$headerContent</div>

4) Don't wait for next steps guys !!!! you are done with the functionality.
This is the easiest way to integrate the web content in theme.
Post a Comment