Monday, December 29, 2014

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







No comments:

Post a Comment

Total Pageviews

Number Of Unique Visitor

Free counters!