Sunday, 13 September 2015

Including a portlet in a theme

Sometimes it is required that we embed a portlet in a theme. We can embed a portlet in a theme through a Velocity template, say, portal_normal.vm.

The embedded portlet usually display a small amount of content. It may be intended for a login screen, for example. It may also be used to display some custom dynamic content. We can use the following steps to add a portlet to a theme:
1. Create a Embed portlet and deploy it.
2. In the portal_normal.vm file of the Noir theme add the following
Velocity code:
<div>
$theme.runtime("embed_WAR_embedportlet_INSTANCE_6CMo")
</div>

   Note : Portlet name you can find by clicking on Configuration -> Sharing -> Anywebsite3. Re-deploy the Noir theme and refresh the page. The embedded portlet shows with borders.
4. Click on the configuration icon of the Embed portlet. Click on Look and Feel.
5. Uncheck Show Borders and click on Save.
6. Close Look and Feel and refresh the page – the portlet borders are gone.
You can see This is the Embed portlet in the screenshot above, which is the text displayed by the Embed portlet.
You can also use the following configuration in ${PLUGINS_SDK_HOME}/themes/embed-portlet/docroot/WEB-INF/portlet.xml to turn off the borders:
<portlet-preferences>
    <preference>
      <name>portlet-setup-show-borders</name>
      <value>false</value>
    </preference>
</portlet-preferences>
You can even embed multiple portlets in a theme.

No comments:

Post a Comment