Add Portlet(Out of Box) to Control Panel

Today we learn how to move a Out of box portlet from Application menu to Control panel.

 Ex- Loan Calculator from Finance category to Control Panel User Section.







This can be done by 2 ways:-






A) Direct change in liferay-display.xml and liferay-portlet.xml in server.
B) By writing EXT


First we discuss 

A)Direct change in liferay-display.xml and liferay-portlet.xml in server.

Step1 :- Enter Portlet in control panel

Go to tomcat-7.0.42\webapps\ROOT\WEB-INF and open liferay-portlet.xml and search for loan
and then put the entries of <control-panel-entry-category> and  <control-panel-entry-weight>.
Ex-

<portlet>
<portlet-name>61</portlet-name>
<icon>/html/icons/loan_calculator.png</icon>
<struts-path>loan_calculator</struts-path>
<control-panel-entry-category>users</control-panel-entry-category>
<control-panel-entry-weight>1.0</control-panel-entry-weight>
<remoteable>true</remoteable>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<css-class-wrapper>portlet-loan-calculator</css-class-wrapper>
</portlet>

Step2 :- Remove from Application

Go to tomcat-7.0.42\webapps\ROOT\WEB-INF and open liferay-display.xml and search for Finance category and remove portlet id 61 from finance category to hidden category. 

Ex-

<category name="category.finance">
<portlet id="16" />
// remove from here
</category>
<category name="category.hidden">
  <portlet id="61" />       // enter here
<portlet id="9" />
<portlet id="15" />
                  .
                  .
                  .
</category>

And Restart Server.Thats it see the output:-



As you see their is no Loan Calculator in Finance category.


And Loan Calculator is availabel in Control Panel Users

Now we Discuss the second Approach

B) By writing EXT

Step1:- Create a Ext project in eclipse


Step2 :- Enter Portlet in control panel

Open liferay-portlet-ext.xml and  provide entry for control panel. Ex-

<liferay-portlet-app>
<portlet>
<portlet-name>61</portlet-name>
<icon>/html/icons/loan_calculator.png</icon>
<struts-path>loan_calculator</struts-path>
<control-panel-entry-category>users</control-panel-entry-category>
<control-panel-entry-weight>1.0</control-panel-entry-weight>
<remoteable>true</remoteable>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<css-class-wrapper>portlet-loan-calculator</css-class-wrapper>
</portlet>
</liferay-portlet-app>

Note:-These entries can be copied from liferay-portlet.xml of server.

At this point if we deploy our Ext portlet is available in Control panel but also in application.

Step3 :- Remove from Application

For removing we have to use liferay-display.xml but their is no such file in Ext so just copy from server and paste in Web-INF


and then remove portlet id 61 from finance category to hidden category as:-

<category name="category.finance">
<portlet id="16" />
// remove from here
</category>
<category name="category.hidden">
  <portlet id="61" />       // enter here
<portlet id="9" />
<portlet id="15" />
                  .
                  .
                  .
</category>

Step4 :- Deploy the Ext

Then stop server Right Click on build.xml--->Liferay-->SDK--->direct-deploy
 and restart server and check the output.






Hope this Help...


Related Post:-







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:-