Friday, 6 February 2015

How to embed a Web Content on your theme?

Requirement:
If you want to display any web content in all the pages then embed that web content in to  theme.



Open portal_normal.vm file of your theme(docroot/_diff/templete/portal_normal.vm)

<pre>
<div id="image-slider">





#set ($VOID = $velocityPortletPreferences.setValue('groupId', $themeDisplay.getCompanyGroupId().toString()))
#set ($VOID = $velocityPortletPreferences.setValue('articleId', $webContentID))
#set ($VOID = $velocityPortletPreferences.setValue('portletSetupShowBorders', 'false'))
#set ($portlet_id = '56')
#set ($my_portlet_id = "${portlet_id}_INSTANCE_ABC1")
$theme.runtime($my_portlet_id, "", $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()
</div>
</pre>


                             likewise 


<pre>
<div id="image-slider">





#set ($VOID = $velocityPortletPreferences.setValue('groupId', $themeDisplay.getScopeGroupId().toString()))
#set ($VOID = $velocityPortletPreferences.setValue('articleId', '16806'))
#set ($VOID = $velocityPortletPreferences.setValue('portletSetupShowBorders', 'false'))
#set ($portlet_id = '56')
#set ($my_portlet_id = "${portlet_id}_INSTANCE_1234")
$theme.runtime($my_portlet_id, "", $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()
</div>
</pre>

If you want to put two different instance of web content display portlet
 on same page and want to display different web content on it, You'll 
need to modify its instance id.
So make sure value for instance id in header and footer is different.

#set ($my_portlet_id = "${portlet_id}_INSTANCE_1234")


If you have used _INSTANCE_1234 in header then use _INSTANCE_5678 in footer code.