How to Show the Minimize and Maximize button on Liferay 6.x Portlet for All Logged In Users

liferay 6.x portal default portlet configuration does not display minimize and maximize icons on portlet headers. These buttons are only available to admin role users. For one of our projects, we had to display the minimize and maximize button for all of our logged in users. We tried to do a lot of research and realized that there is no easy way of doing it in liferay 6.x portal. This post is about a simple workaround we have found which will start showing minimize and maximize icons on all liferay portlets including custom and out of the box portlets.

This workaround requires us to modify a liferay core JSP file. You need to carefully follow below steps to start displaying the minimize and maximize icons on all portlets. We are using a tomcat bundle for describing below steps, in case you are using a different bundle you may need to look for specific directories in respective bundles.

  1. Go to the directory liferay-portal-6.x/tomcat-xxx/webapps/ROOT/html/portal
  2. Open the file render_portlet.jsp
  3. Find below text line in the render_portlet.jsp file
  4. portletDisplay.recycle();
    
  5. Add below code snippet just above this line
  6. if (themeDisplay.isSignedIn()) 
    {         
    showMaxIcon = true;         
    showMinIcon = true; 
    } 
    

The if condition "themeDisplay.isSignedIn()" is going to verify if the user is logged in and display the minimize and maximize icons for all logged in users on all portlets. In case you want to show the minimize and maximize icons to all users including guests you can remove this if condition and replace it with below snippet

showMaxIcon = true;
showMinIcon = true;

We spent a lot of time finding out this workaround, hope this helps others. Let us know if you can think of a better approach to do the same thing.

Post a Comment Default Comments

  1. I want to show the maximize icon only to my custom portlet.Can you please tell me how to do it.

    I used the below in my render method. But no use.

    themeDisplay.getPortletDisplay().setShowMaxIcon(true);

    ReplyDelete
  2. Adding this to your portal-ext.properties does it.

    # Show the portlet maximize icon for Guest users (always show icon).
    layout.guest.show.max.icon=true

    Thanks
    ~Mehul

    ReplyDelete
  3. Creating a hook with this file is cleaner, but thanks for idea :-)

    ReplyDelete
  4. This is very good article. It helps so much to me.

    ReplyDelete

Individuals who comment on FromDev at regular basis, will be rewarded in Top Commenter section. (Comments are selectively moderated so please do not spam)

emo-but-icon

...

item