Monday, December 29, 2014

Add Portlet(Custom portlet) to Control Panel

Today we learn how to move a Custom portlet from Application menu to Control panel.


Step 1:- Create a simple Hello World Portlet 

 Create a simple Hello World Portlet and provide display Category as HelloWorld so this portlet is  available in Category HelloWorld.




liferay-display.xml

<?xml version="1.0"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.2.0//EN" "http://www.liferay.com/dtd/liferay-display_6_2_0.dtd">

<display>
<category name="HelloWorld">
<portlet id="hello-world"></portlet>
</category>
</display>

So this portlet is shown as:-





Step 2:- Search For DTD

Go to the URL mention in liferay-portlet.xml  (http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd) and

a)search for tag  <control-panel-entry-category>

<!--
Set the control-panel-entry-category value to "my" to make this portlet
available within the My Account administration of the user. Set the value to
"apps", "configuration", "sites", or "users" to make it available in the Control
Panel under that category. Set the value to "site_administration.configuration",
"site_administration.content", "site_administration.pages" or
"site_administration.users" to make it available in the Site Administration
under that category. Legacy values from previous versions of Liferay will be
automatically mapped to the new values: "content" to
"site_administration.content", "portal" to "users", and "server" to "apps".
-->

by using this you can decide in which category you want to display your portlet.

b)search for tag  <control-panel-entry-weight>

<!--
Set the control-panel-entry-weight value to a double number to control the
position of the entry within its Control Panel category. Higher values mean
that the entry will appear lower in the Control Panel menu.

-->

So we use a) and b) in liferay-portlet.xml as

<portlet>
<portlet-name>hello-world</portlet-name>
<icon>/icon.png</icon>
<control-panel-entry-category>sites</control-panel-entry-category>
<control-panel-entry-weight>1.0</control-panel-entry-weight>
<header-portlet-css>/css/main.css</header-portlet-css>
<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
<css-class-wrapper>hello-world-portlet</css-class-wrapper>
</portlet>

Deploy it and this portlet shown in sites .


But there is a problem this portlet shown in Control panel as well as in Applicaton so we have to remove it from Application.



Step 3:-Hiding portlet from Application

Find the file liferay-display.xml in server
(\tomcat-7.0.42\webapps\ROOT\WEB-INF\liferay-display.xml)
and search the tag <category name="category.hidden"> use this category in your  liferay-display.xml

<display>
<category name="category.hidden">
<portlet id="hello-world"></portlet>
</category>
</display>

Note:-If you use any other Category like category.community or  category.finance then this portlet goes to that particlar category.

And thats it Your Portlet is now available in Control panel and not in Application.

In the next blog we learn how to move a Out of box portlet from Application menu to Control panel.






Hope this Help...

Related Post:-






1 comment:

Total Pageviews

Like Us on Facebook

Number Of Unique Visitor

Free counters!