Pages

Monday 29 September 2014

Disable Built-in portlet (Default) in Liferay

Hi Friends,

As we know liferay comes with bundle of 60+ App(portlet) built in with default installation.
 Like

  • Asset Publisher
  • Blog
  • Blog Display
  • Navigation
  • Tag
  • Breadcrumb
WE can use them as per requirement.
Still many of portlet are not useful when we designing for real application. Therefore It is recommended that we have to disable them so that these portlet will not appear in App section as well as control panel.

When we disable any portlet JVM does not load the classes related to that particular portlet so we can also optimized the Liferay portal by disabling the unused portlet.

To disable a built-in portlet we have two options.

Using lifeary-portlet.xml


1. Directly modified the liferay-portlet.xml file located at following path

<liferay installation><tomcat-7.0.42 or your app server>\webapps\ROOT\WEB-INF\

2. find the portlet with id if you know or by name as well
for example I want to disable the liferay search portlet then we know its id is 2

3. you will get a block like this



<portlet>
<portlet-name>2</portlet-name>
<icon>/html/icons/my_account.png</icon>
<struts-path>my_account</struts-path>
<portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
<control-panel-entry-category>my</control-panel-entry-category>
<control-panel-entry-weight>1.0</control-panel-entry-weight>
<preferences-owned-by-group>true</preferences-owned-by-group>
<use-default-template>false</use-default-template>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<header-portlet-css>/html/portlet/users_admin/css/main.css</header-portlet-css>
<footer-portlet-javascript>/html/portlet/users_admin/js/main.js</footer-portlet-javascript>
<css-class-wrapper>portlet-users-admin</css-class-wrapper>
<add-default-resource>true</add-default-resource>
<system>true</system>

</portlet>

4. now at the end of this block just before closing of portlet tag </portlet> put the following line,

<include>false</include>

and the above code will look like this after changes.



<portlet>
<portlet-name>2</portlet-name>
<icon>/html/icons/my_account.png</icon>
<struts-path>my_account</struts-path>
<portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
<control-panel-entry-category>my</control-panel-entry-category>
<control-panel-entry-weight>1.0</control-panel-entry-weight>
<preferences-owned-by-group>true</preferences-owned-by-group>
<use-default-template>false</use-default-template>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<header-portlet-css>/html/portlet/users_admin/css/main.css</header-portlet-css>
<footer-portlet-javascript>/html/portlet/users_admin/js/main.js</footer-portlet-javascript>
<css-class-wrapper>portlet-users-admin</css-class-wrapper>
<add-default-resource>true</add-default-resource>
<system>true</system>
               <include>false</include>

</portlet>



5. save the file & restart the server just it.

Using lifeary-portlet-ext.xml


1. create a ext plugin project.

go to
docroot/WEB-INF/ext-web/docroot/WEB-INF/

2.
open liferay-portlet.xml file



& place the below code before closing  </liferay-portlet-app>

<portlet>
<portlet-name>2</portlet-name>
<icon>/html/icons/my_account.png</icon>
<struts-path>my_account</struts-path>
<portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
<control-panel-entry-category>my</control-panel-entry-category>
<control-panel-entry-weight>1.0</control-panel-entry-weight>
<preferences-owned-by-group>true</preferences-owned-by-group>
<use-default-template>false</use-default-template>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<header-portlet-css>/html/portlet/users_admin/css/main.css</header-portlet-css>
<footer-portlet-javascript>/html/portlet/users_admin/js/main.js</footer-portlet-javascript>
<css-class-wrapper>portlet-users-admin</css-class-wrapper>
<add-default-resource>true</add-default-resource>
<system>true</system>
               <include>false</include>

</portlet>

3.
Deploy the war in deploy folder of your app server.

4. since its a ext plugin so you will have to restart the server after deployment.



Please let me know if you have any query. 


Keep sharing, what you learn... :)





No comments:

Post a Comment