« Back

Customizing Social Office 3.0 using plugins

General Blogs February 17, 2014 By Jamie L Sammons

 In the Liferay Developers Guide there is a nice little tidbit titled "Creating Plugins to Extend Plugins" found here. This basically allows a lot of the same principles used with hook plugins when customizing Liferay.  The difference here is that it allows you to customize portlet plugins with plugins.  As with hook plugins this allows a degree of separation between your customization's and the default application.

This same concept can also be used to customize Social Office plugins (including Social Office EE plugins).  The name of the new plugin must match the name of the original plugin since the so-hook expects the original name.

We had a need to hide the two public Site types in Social Office (Open and Public Restricted) since we share our Portal instance with our Clients.  

Do the following to customize the so-portlet:

  1. In Liferay IDE create a new Liferay Portlet Plugin project called: so-portlet
  2. Expand the new so-portlet project and delete everything below docroot
  3. Copy the original so-portlet WAR file into the root directory of the new so-portlet project in eclipse:

  4. Edit the build.xml ANT script and add the following property to the script:
        <property
            name="original.war.file"
            value="so-portlet-6.2.0.2-ce-ga1-20140210151141114.war"
        />
    
  5. Run the all Ant task.  A new tmp directory will show up at the root of the so-portlet project (may need to refresh).  At this point this is the contents of the original war file.  
  6. Copy tmp/WEB-INF/liferay-plugin-package.properties to docroot/WEB-INF in the so-portlet project (Create WEB-INF if it doesn't already exist).
  7. Modify liferay-plugin-package.properties and change module-incremental-version to 10.  This will cause your custom so-portlet to always take priority over the default so-portlet.
  8. Copy tmp/sites/edit_site.jsp to docroot/sites
  9. Modify docroot/sites/edit_site.jsp and remove the lines that define Public and Public Restricted Sites (Search for TYPE_SITE_OPEN and TYPE_SITE_PUBLIC_RESTRICTED).
  10. Run the all Ant task again and now tmp will be a combination of the default war file and your cusomizations.  This also generates a custom war file in the plugins SDK dist folder that can be deployed to a Liferay server

That's pretty much it.  This procedure can be used with pretty much any portlet project including EE versions.

Threaded Replies Author Date
Cool post, Jamie! Thanks for sharing with the... Juan Fernández February 19, 2014 7:37 AM
I have the same requirements in my project. But... Muhammed Shafeek V February 24, 2014 8:36 PM
Hi Jamie, I have the same proble to understand... Gaetano Calcagno April 9, 2014 7:52 AM
rename the "SocialOffice.lpkg" in... Gaetano Calcagno April 28, 2014 6:21 AM
Can we modify the java classes as well using... Praveen Singh Bais April 30, 2014 2:25 AM
Yes. You have to copy the folder WEB-INF under... Gaetano Calcagno April 30, 2014 6:54 AM
Thanks for quick response Gaetano, had to copy... Praveen Singh Bais May 1, 2014 6:07 AM
[ As per my understanding for overriding other... Gaetano Calcagno May 30, 2014 6:05 AM
Thanks Gaetano Praveen Singh Bais May 31, 2014 3:16 AM
This procedure was successful to me only when I... Yannis Konstas July 16, 2014 2:25 AM
If I add this project on Tomcat of Eclipse, it... Fil Giu July 1, 2016 9:11 AM

Cool post, Jamie! Thanks for sharing with the community!
Juan
Posted on 2/19/14 7:37 AM.
I have the same requirements in my project. But I don't know where to get so-portlet war file. Can you?
Posted on 2/24/14 8:36 PM.
Hi Jamie, I have the same proble to understand how to make the war of the portlet that I want to modify.

I have to modify the so-portlet.

Up to now, I have the source code of Social Office 3.0 , I have imported in Eclipse the so-portlet to make the war from myself, but there are a lot of errors that I have to manage.

Is this the right way or there's another one to do this?

Thanks
Gaetano
Posted on 4/9/14 7:52 AM.
rename the "SocialOffice.lpkg" in "SocialOffice.zip" and inside I can find all the 18 portlet of social office.
Posted on 4/28/14 6:21 AM in reply to Gaetano Calcagno.
Can we modify the java classes as well using this procedure ?
In case we need to modify the actual business logic in one of the portlets?
Posted on 4/30/14 2:25 AM in reply to Gaetano Calcagno.
Yes. You have to copy the folder WEB-INF under /docroot, and after you can modify all the java classes.

Copy all the WEB-INF folder is necessary to avoid the dependencies.

Bye
Gaetano
Posted on 4/30/14 6:54 AM in reply to Praveen Singh Bais.
Thanks for quick response Gaetano, had to copy the source files under docroot/WEB-INF/src. Now we are able to extend existing portlet classes using custom classes.
As per my understanding for overriding other config files like portlet.xml,liferay-display.xml, we need to copy each to docroot/WEB-INF folder ?
Posted on 5/1/14 6:07 AM in reply to Gaetano Calcagno.
[ As per my understanding for overriding other config files like portlet.xml,liferay-display.xml, we need to copy each to docroot/WEB-INF folder ? ]

Yes, every file that you have to modify needs to be copied in docroot/WEB-INF in the same directory structure (as this guide explain).

Bye
Gaetano
Posted on 5/30/14 6:05 AM in reply to Praveen Singh Bais.
Posted on 5/31/14 3:16 AM.
This procedure was successful to me only when I use build-common-plugin-ext.xml. Should this be done with build-common-plugin.xml?
Posted on 7/16/14 2:25 AM.
If I add this project on Tomcat of Eclipse, it doesn't work.
I have to build the war and deploy it from control panel, then it works fine!
Posted on 7/1/16 9:11 AM in reply to Yannis Konstas.