Pages

Tuesday, 9 April 2013

Embed or Integrate web content in theme- Liferay6.X.X

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" "http://www.liferay.com/dtd/liferay-look-and-feel_5_0_0.dtd">
<look-and-feel>
    <compatibility>
        <version>6.0.0+</version>
    </compatibility>
   <company-limit>
        <company-includes /> 
        <company-excludes /> 
   </company-limit>
    <theme id="drupal-garland" name="drupal-garland">
        <template-extension>vm</template-extension> 
    <settings>
          <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" /> 
  </settings>
 </theme>
</look-and-feel>
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.




No comments:

Post a Comment