Saturday, September 5, 2015

Embedding a Portlet in Web Content/Journal Article

We already know how to create a Web Content in Liferay. Today we will embedded a portlet in web content. We know that there are two types of portlet:-

1)Instanceable Portlet
 Instanceable portlet are those portlet that can be added more than one time on a single page. Ex- Asset Publisher.

2)Non - Instanceable Portlet
Non - Instanceable portlet are those that can be added only single time on a page. Ex- Loan Calculator.

We can embedded both type of portlet in web content by using portlet id and instance Id.

How do we get Portlet Id ?? 

Their are two ways:-

1)By portlet-custom.xml
Go to ..\webapps\ROOT\WEB-INF\portlet-custom.xml this file contain all OOTB portlet entries. You can get the Portlet Id from this file.

2)By Using Configuration
Add portlet on the page click on wrench icon and Click on Configuration.

than click on sharing

Here 101 is Portlet Id of Asset Publisher Portlet and abcd is instance id. Each Asset Publisher portlet has same portlet Id and different instance Id.

Non-Instantceable portlet has only portlet Id but not contain any instance id. Ex- Loan Calculator Portlet.

Here 61 is the Portlet Id of Loan Calculator Portlet.

For embedding a portlet we use basic xml tag provided by liferay:-

So lets embedded both types of portlet one by one.

A)Embedded Instanceable Portlet in Web Content
First Go to your home page and add Web Content Display portlet on Page. Then Click on Add

After that provide title and source as:-

and Click Publish. Now See the output:-

B)Embedded Non-Instanceable Portlet in Web Content
Now similarly add Web Content Display portlet and click add and provide title and Source as:-

Now Click Publish and see the output as:-

No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!