Injecting a portlet using Dynamic Container

The mechanism

If you want to inject a portlet to every page in a site, you might add it directly to the shared layout (sharedlayout.xml). However, in case you have more than one extension that overrides sharedlayout.xml, only the last loaded one takes effect. This leads to trouble that portlets injection cannot be solved in packaging, it will require extra tasks in deployment (like merging several layouts from different projects).

As of 4.1, the trouble is solved by the Dynamic Container feature. A shared layout and an extension get involved in how it works:

So in this way, whenever the named container instance is put into a page, or all pages via sharedlayout.xml, the portlet injection is done automatically. An extension does not have to override the layout.


In the following example, you inject the "Help" portlet (a built-in, for simplification) into all pages of the Intranet site. The Help portlet is already featured at the top right of the homepage by default, so you will add another one to the left.

  1. Make a portal extension as described in Portal extension section.

  2. Edit WEB-INF/conf/configuration.xml:

            xsi:schemaLocation="http://www.exoplatform.org/xml/ns/kernel_1_2.xsd http://www.exoplatform.org/xml/ns/kernel_1_2.xsd"

                <object type="org.exoplatform.portal.config.serialize.PortletApplication">
                <field name="state">
                    <object type="org.exoplatform.portal.config.model.TransientApplicationState">
                    <field name="contentId">

In which:

Default Dynamic Container instances

Here are the Dynamic Container instances in the Intranet site:

For a customized site, you can manage Dynamic Containers by customizing sharedlayout.xml. The configuration sample is given above. There are two templates of Dynamic Container:

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus