Saturday, 21 September 2013


Creating a new category in Control Panel  


While development of any big portal, we need to customize control panel also. In such a case, its generally needed to make a new category in control panel and adding portlet in it. So, here are the steps, hope you'll find it helpful.



1. Override the class PortletCategoryKeys (in ext-impl\src\com\liferay\portal\util\PortletCategoryKeys.java)



     package com.liferay.portal.util;



/**



 * @author apoorva.prakash



 *



 */



public class PortletCategoryKeys {



 public static final String CONTENT = "content";



 public static final String MY = "my";



 public static final String PORTAL = "portal";



 public static final String SERVER = "server";



 public static final String MYCATEGORY = "mycategory";



 public static final String[] ALL = {MY, CONTENT, MYCATEGORY , PORTAL, SERVER};



}







Put the category in ALL array in the order you wish to appear your category.



2. Now add portlet in this category using the following entry in liferay-portlet-ext.xml file

<portlet>

    <portlet-name>portlet_id</portlet-name>

 <control-panel-entry-category>mycategory</control-panel-entry-category>

 <control-panel-entry-weight>1</control-panel-entry-weight>

</portlet>





here  portlet_id is the id of the portlet that you wish to add in our custom category. Specify the name of the category in <control-panel-entry-category> entry and sequence of portlet appearance in determined through <control-panel-entry-weight>. The higher the weight, upper will be the portlet(weight can also be in floating number).



3. Now an important point, we must enter the category name entry in language-ext.properties file, so that our category can be recognized, otherwise you'll get category name as "category.mycategory"



category.mycategory=My New Category



No comments:

Post a Comment