Hook - Customizing Login


Image

 

What is Hooks.?

Hooks, allow overriding the portal core functionality. Hooks is a feature to catch hold of the properties and JSP files into an instance of the portal as if catching them with a hook.

In general, hooks would be very helpful tools to customize the portal without touching the code part of the portal.

1)Creating a Hook

Hooks are stored within the hooks directory of the plugins directory.  Open cmd

Ex:

D:\Hooks\plugins\hooks>create.bat login "login"

You should get a BUILD SUCCESSFUL message from Ant, and there will be a new folder inside of the hooks folder in your Plugins SDK. Notice that the Plugins SDK automatically appends "-hook" to the project name when creating this folder.

2)Deploying the Hook

Open a cmd, hooks/login-hook directory and enter this command:

ant deploy

You should get a BUILD SUCCESSFUL message, which means that your hook is now being deployed. If you switch to the terminal window running Liferay, and wait for a few seconds, you should see the message "Hook for login-hook is available for use." However, unlike portlets or themes, your new hook doesn't actually do anything yet.

3)Overriding a JSP

One of the simplest tasks a hook can perform is replacing a portal JSP. In this example we will modify the create_account page in Login portlet. First, create the directory hooks/login-hook/docroot/META-INF/custom_jsp. Next, edit hooks/login-hook/docroot/WEB-INF/liferay-hook.xml, and add the following between <hook></hook>:

<custom-jsp-dir>/WEB-INF/custom_jsps</custom-jsp-dir>

Now, any JSP you place inside the custom_jsp directory will replace its original inside your Liferay instance when your hook is deployed. The directory structure inside this folder must mirror the one within liferay-portal-[version]/tomcat-7.0.27/webapps/ROOT. To override the create account, copy liferay-portal-[version]/tomcat-7.0.27/webapps/ROOT/html/portlet/create_account.jsp to hooks/login-hook/docroot/WEB-INF/custom_jsps/html/portlet/create_account.jsp. You will have to create all the intervening directories first.

EXAMPLE:  (this is existing create account page)

 

 

CUSTOMIZING THE CREATE ACCOUNT PAGE:

 

Step 1: Here I am going to remove “Middle Name” “Last Name” in create_account.jsp.

Step 2: After make a few changes. Deploy hook and wait until it is deployed successfully. Then, click create account.

 

 

Step 3: Removing Capcha (Text verification)

 

webapps\ROOT\WEB-INF\classes\portal-ext.properties

just add "captcha.max.challenges=-1" and start up liferay. That should do it.

 

Step 4: For “Gender” and “Birthday” we can give disable through Liferay Control Panel..

 

 

Click Portal Settingà

 

 

Click Userà

Then, give disable for “Gender” and  “Birthday”. And click save.

 

Then, reload the page and click create account.

(CUSTOMIZED CREATE ACCOUNT PAGE)

It’s not about ideas It’s about making ideas happen !!!

Image Image Image