Liferay六年中持续被评为Gartner水平门户魔力象限领导者。 原因是
« 返回到 Layout

Add runtime portlets to a layout

Intro #

In some cases you may need to have a portlet show up on every single page every time. Instead of adding it manually everytime you create a new page, you can embed portlets in your custom Layout Template

Since Liferay version 4.3.x we have the ability to create runtime portlets and store them in layout files.

Layout example #

Here is an example:

 
  <table id="layout-grid">
   <tr>
    <td class="lfr-column thirty" id="left" valign="top">
     $processor.processPortlet("71")
     $processor.processColumn("left")
    </td>
    <td class="lfr-column seventy" id="column-1" valign="top">
     $processor.processPortlet("73")
     $processor.processColumn("column-1")
    </td>
   </tr>
  </table>
 

This is a typical layout template, with runtime portlets (navigation and breadcrumb) forced to always be above every other portlet.

Managing Instanceable Portlets #

In case you want to embed instanceable portlets, you can do it this way:

$processor.processPortlet("71_INSTANCE_abc1")

where abc1 can be a random four character code to differentiate instances of the same portlet being placed in the same page.

Embeding Custom Portlets #

If we need to add custom portlets to a page, we can do it this way:

$processor.processPortlet("portletId_WAR_webapplicationcontext_INSTANCE_abc2")

Configuring embedded portlets #

Unfortunately the $processor.processPortlet(...) mechanism does not allow configuration (portlet preferences) to be passed to the portlets. However, there's a workaround: You can use the same mechanics as in a theme - taken from LPS-15746:

$velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
$velocityPortletPreferences.setValue("header-type", "none")
$velocityPortletPreferences.setValue("root-layout-type", "absolute")
$velocityPortletPreferences.setValue("root-layout-level", "2")
$velocityPortletPreferences.setValue("included-layouts", "buderusleft")
$velocityPortletPreferences.setValue("nested-children", "true")
$theme.runtime("71_INSTANCE_abcd", "", $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset() 

Related Articles #

0 附件
52274 查看
平均 (2 票)
满分为 5,平均得分为 3.0。
评论
讨论主题回复 作者 日期
any details about runtime for journal content... delang j 2008年11月24日 上午7:44
I can still minimize, maximmize and configure... Dennis Greiffenberg 2010年6月8日 下午11:37
Is it not possible to do this for 'Poll... Bart Simpson 2011年9月22日 上午4:34
How can I add a different journal portlets to... armando ponce 2012年3月28日 上午8:39
added the information for how to configure a... Olaf Kock 2012年6月13日 上午11:44
From where do you get a portlet instance id?... the denu 2012年7月10日 上午6:37
I'd tried it with Liferay 6.1.1, but It doesn't... Juan Antonio Girón 2012年10月1日 上午7:55
Please refer below post: ... Himanshu Bhandari 2015年6月3日 下午10:47

any details about runtime for journal content which is display article
在 08-11-24 上午7:44 发帖。
I can still minimize, maximmize and configure the portlets (owner of the page, since private page pre-populated with default content). How can I prevent users from changing these settings?
在 10-6-8 下午11:37 发帖。
Is it not possible to do this for 'Poll Display' portlet ?
$processor.processPortlet("59")
for Poll display doesn't work.
在 11-9-22 上午4:34 发帖以回复 Dennis Greiffenberg
How can I add a different journal portlets to the layout and make the unique, so that when an author selects content for the journal, don't affect other journals?
在 12-3-28 上午8:39 发帖。
added the information for how to configure a portlet
在 12-6-13 上午11:44 发帖以回复 armando ponce
From where do you get a portlet instance id? For example: portletId_WAR_webapplicationcontext_INSTANCE_abc2, and I mean that is custom portlet, not one included with Liferay?
在 12-7-10 上午6:37 发帖以回复 Olaf Kock
I'd tried it with Liferay 6.1.1, but It doesn't work.
How can I use "$processor.processPortlet" with Liferay 6.1.1?
在 12-10-1 上午7:55 发帖以回复 Maciej Witwicki
Please refer below post:

http://www.liferay.com/community/forums/-/message_boards/message/31829783
在 15-6-3 下午10:47 发帖以回复 Maciej Witwicki