Monday 30 May 2011

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.

8 comments:

  1. again.......well written..!!!!

    ReplyDelete
  2. You can follow the below link.
    http://tariqliferay.blogspot.com/2015/02/how-to-add-portlet-in-liferay-theme.html

    ReplyDelete
  3. Nice tutorial!
    I have make some new liferay theme, you can download free at www.liferaytheme.com

    ReplyDelete
  4. Nice woork i was looking for somthing like this clean and simple.

    ReplyDelete
  5. Mấy bạn có thể chỉ mình cách tạo footer không. cảm ơn các bạn

    ReplyDelete
  6. Mấy bạn có thể chỉ mình cách tạo footer không. cảm ơn các bạn

    ReplyDelete
  7. thank you :). straight and easy

    ReplyDelete