14 November, 2013

When to use Hook ?

Hooks are the most powerful plugin provided by liferay which can be used for customizing Liferay’s core features.
We can definitely use EXT plugin which can be achieved by Hook plugin but for best practices, we should use hook plugin as it is hot-deployable and also easy for upgradation/migration process.


Now you have to make sure that before you start actual development, you should know whether to use Hook or EXT.
Here I have provided explanation about that so that each developer can decide what needs to use when...

Basically hooks will be useful for :

1)  Override Portal.properties (Not all properties)
Not all portal properties can be overridden via a hook. The supported properties
are given in http://www.liferay.com/dtd/liferay-hook_6_1_0.dtd
Also one important thing is, what ever property have multiple comma separated value cannot be removed or change the sequence, we can only add our own new property
like
users.form.update.main = CIGNEX

2) Override Language Properties


You can override language.propeties (Including locale specific),


3) Customize JSPs


=> If you want to add your custom logic in existing JSP so that original code works as it is, for that you can use below code


Let say i am overriding search.jsp file of blog portlet,

<liferay-util:buffer var="html">
    <liferay-util:include page="/html/portlet/blogs/search.portal.jsp" />
</liferay-util:buffer>
<%
html = StringUtil.add(
    html,"This is Jignesh","\n");
%>
<%= html %>
=> If you want to customize existing logic of jsp  only then you don't need to add below code and can modify the code as per your requirement
<liferay-util:buffer var="html">
    <liferay-util:include page="/html/portlet/blogs/search.portal.jsp" />
</liferay-util:buffer>
 custom-jsp-dir : Used to locale the path of JSP which you are going to override
custom-jsp-global : Used to create site specific hook adapter which you can apply for specific sites

4)  Customize Indexer class for search
 We can customize existing indexer class and can add any custom fields to in lucene indexer and can make searchable. 

5) Customize existing localServiceImpl classes

6) Customize Existing servlet filters

7) Customize existing struts action classes

Popular Posts

Featured Post

Liferay 7.3 compatibility matrix

Compatibility Matrix Liferay's general policy is to test Liferay Portal CE against newer major releases of operating systems, open s...