Liferay Hooks are used to customize the liferay portal. We have many kinds of hook plugins one of the hook is Portal Properties hook.
Introduction to Liferay Hook Plugins
Portal properties hook overriding the existing portal properties and Portal properties hook can modify the some of the portal properties not all the portal properties. The modifiable list of properties are specified in liferay-hook_6_x_x.dtd file.
If the properties are not listen in the liferay-hook_6_x_x.dtd file then we cannot modify it from portal properties hooks. Assume we want to modify login.events.pre ,login.events.post properties then we will use Portal Properties Hooks.
If the portal properties are not listed in above then its not possible to override from portal properties hook plugins then we have to use portal-ext.properties file.
Existed Behavior of Liferay portal Create Account Page
In the liferay portal create account page we cannot find password field that user can create his own password at the time of registration.
After registration user will get mail with auto generated password to login into portal and then he/she can change the password from his/her my account page password section.
Existed User Create Account Page in Liferay
Customer Expected Behavior of Create Account Page
Now assume we want create account page so that user can choose his/her own password at time of registration
The following are basic steps we should consider
Here our requirement is customize the existed liferay portal so best choice is hook plugins.
We have many kind of hook plugins so first we need to check with any portal property that can full fill out requirement.
Need to search in liferay-hook_6_x_x.dtd for appropriate portal property that can solve our problem.
If we find relevant portal property then we will choose portal properties hook Plugin to implement it otherwise we should go for other type of hook Plugin.
In our case “login.create.account.allow.custom.password” is full fill our requirement. “login.create.account.allow.custom.password” is portal property that will allow user to choose custom password at the time of registration means it will accommodate two more user input fields in the create account page.
Implement Solution using Portal Properties Hook
Direct Steps
Step:1
Create Liferay Hook Project using below Article
Liferay Hook Plugin Development with Liferay IDE
Step:2
Configure portal properties file name in “liferay-hook.xml” its in hook Plugin WEB-INF directory (/Sample-hook/docroot/WEB-INF/liferay-hook.xml)
Add following configuration in “liferay-hook.xml
<hook>
<portal-properties>portal.properties</portal-properties>
</hook>
Step:3
Create “portal.properites” file in Plugin Hook src directory (/Sample-hook/docroot/WEB-INF/src/portal.properties)
Step:4
Add overridden property name and its value in “portal.properites” file that is Plugin Hook src directory and possible overridden portal properties are available in “liferay-hook_6_x_x.dtd”
Add Overridden Portal Property in hook “portal.properties” files as follows
login.create.account.allow.custom.password=true
Step:5
Once we done all above steps deploy the Hook Plugin by double click on deploy target in the ANT view of eclipse or you can use “ant deploy” target from command prompt.
Once Portal Properties Hook Plugin successfully deployed ,now go to create account page then you can see password fileds in the page
The following screen shows you password filed
Crete Portal properties Hook using Liferay IDE Graphical User Interface
First we need to create Liferay Hook Plugin please follow the article and Create liferay hook Plugin
Liferay Hook Plugin Development with Liferay IDE
Now select the created hook Plugin in the project explorer
Go to File--> New Liferay Hook Configuration
now you can see dialog window select portal properties check box then click on next
Now you can see another dialog there you can see two sections in the bottom section is for adding portal properties. Now click on Add button
Now you will get another window there you can see property name and value input fields . For property name you can see “select” button
Now click on “select” button it will show another dialog to select possible portal properties.
Choose required property then click on OK
Now selected property will be appear in the property filed and enter appropriate values for the property in the values filed.
Click the OK and finally click on the Finish button. Now the portal properties file will be created in the hook src directory (“/Sample-hook/docroot/WEB-INF/src/portal.properties”).
The overridden properties and values are present in the “portal.properties” file
Overriding More Portal Properties
In the project explored go to /Sample-hook/docroot/WEB-INF and double click on “liferay-hook.xml” file then it will be open in editor and we have two views “source” view and “overview”, default view is “overview”
The following is “overview” of “liferay-hook.xml”
Note:
All hook related configuration are placed in “liferay-hook.xml”
In the “overview” you can find “Portal properties” icon with text ,click on that and check the “Customize Liferay Portal Properties” As soon as you check the box then you can see “portal properties” input field and “portal properties overrides” that can have two sections “Name” and “Value”
The following screen show you required input fields
Now we can see Add icon(+) click on Add icon then you can see Name and Value fields in the bottom of “Portal Properties Overrides” input field.
Now in the name field you can see browse button. You can click on browse button then you can see dialog window there you can see all possible portal properties that can be overridden and you can have search field to search properties.
Now select required property and click on OK then it will be appear in the “Override Name” field and enter appropriate value in “Override Value” field
If we want we can also add more values or you can remove values using Add and Remove icons.
Once we done then save the file (Ctrl+S).
In the source view you can see the “liferay-hook.xml” as follows
Ass soon as we save the file then portal property name and overridden value will be written in “portal.proerties” file that is in hook Plugin src directory
Once we done all above steps deploy the Hook Plugin by double click on deploy target in the ANT view of eclipse or you can use “ant deploy” target from command prompt.
Once Portal Properties Hook Plugin successfully deployed then you can see respective changes in the liferay portal.
The following are possible portal properties that we can override using hook plugins
admin.default.group.names
admin.default.role.names
admin.default.user.group.names
asset.publisher.asset.entry.query.processors
asset.publisher.display.styles
asset.publisher.query.form.configuration
auth.forward.by.last.path
auth.public.paths
auto.deploy.listeners
application.startup.events
auth.failure
auth.max.failures
auth.token.ignore.actions
auth.token.ignore.portlets
auth.token.impl
auth.pipeline.post
auth.pipeline.pre
auto.login.hooks
captcha.check.portal.create_account
captcha.engine.impl
com.liferay.portal.servlet.filters.*Filter
company.default.locale
company.default.time.zone
company.settings.form.authentication
company.settings.form.configuration
company.settings.form.identification
company.settings.form.miscellaneous
control.panel.entry.class.default
convert.processes
default.landing.page.path
default.regular.color.scheme.id
default.regular.theme.id
default.wap.color.scheme.id
default.wap.theme.id
dl.file.entry.drafts.enabled
dl.file.entry.processors
dl.repository.impl
dl.store.antivirus.impl
dl.store.impl
dockbar.add.portlets
field.enable.com.liferay.portal.model.Contact.birthday
field.enable.com.liferay.portal.model.Contact.male
field.enable.com.liferay.portal.model.Organization.status
hot.deploy.listeners
javascript.fast.load
journal.article.form.add
journal.article.form.translate
journal.article.form.update
layout.form.add
layout.form.update
layout.set.form.update
layout.static.portlets.all
layout.template.cache.enabled
layout.types
layout.user.private.layouts.auto.create
layout.user.private.layouts.enabled
layout.user.private.layouts.power.user.required
layout.user.public.layouts.auto.create
layout.user.public.layouts.enabled
layout.user.public.layouts.power.user.required
ldap.attrs.transformer.impl
locales
locales.beta
locales.enabled
lock.listeners
login.create.account.allow.custom.password
login.events.post
login.events.pre
login.form.navigation.post
login.form.navigation.pre
logout.events.post
logout.events.pre
mail.hook.impl
my.sites.show.private.sites.with.no.layouts
my.sites.show.public.sites.with.no.layouts
my.sites.show.user.private.sites.with.no.layouts
my.sites.show.user.public.sites.with.no.layouts
organizations.form.add.identification
organizations.form.add.main
organizations.form.add.miscellaneous
passwords.passwordpolicytoolkit.generator
passwords.passwordpolicytoolkit.static
passwords.toolkit
phone.number.format.impl
phone.number.format.international.regexp
phone.number.format.usa.regexp
portlet.add.default.resource.check.enabled
portlet.add.default.resource.check.whitelist
portlet.add.default.resource.check.whitelist.actions
rss.feeds.enabled
sanitizer.impl
servlet.session.create.events
servlet.session.destroy.events
servlet.service.events.post
servlet.service.events.pre
session.max.allowed
session.phishing.protected.attributes
session.store.password
sites.form.add.advanced
sites.form.add.main
sites.form.add.seo
sites.form.update.advanced
sites.form.update.main
sites.form.update.seo
social.activity.sets.bundling.enabled
social.activity.sets.enabled
social.activity.sets.selector
social.bookmark.*
terms.of.use.required
theme.css.fast.load
theme.images.fast.load
theme.jsp.override.enabled
theme.loader.new.theme.id.on.import
theme.portlet.decorate.default
theme.portlet.sharing.default
theme.shortcut.icon
time.zones
upgrade.processes
user.notification.event.confirmation.enabled
users.email.address.generator
users.email.address.required
users.email.address.validator
users.form.add.identification
users.form.add.main
users.form.add.miscellaneous
users.form.my.account.identification
users.form.my.account.main
users.form.my.account.miscellaneous
users.form.update.identification
users.form.update.main
users.form.update.miscellaneous
users.full.name.generator
users.full.name.validator
users.image.max.height
users.image.max.width
users.screen.name.always.autogenerate
users.screen.name.generator
users.screen.name.validator
value.object.listener.*
Introduction to Liferay Hook Plugins
Portal properties hook overriding the existing portal properties and Portal properties hook can modify the some of the portal properties not all the portal properties. The modifiable list of properties are specified in liferay-hook_6_x_x.dtd file.
If the properties are not listen in the liferay-hook_6_x_x.dtd file then we cannot modify it from portal properties hooks. Assume we want to modify login.events.pre ,login.events.post properties then we will use Portal Properties Hooks.
If the portal properties are not listed in above then its not possible to override from portal properties hook plugins then we have to use portal-ext.properties file.
Existed Behavior of Liferay portal Create Account Page
In the liferay portal create account page we cannot find password field that user can create his own password at the time of registration.
After registration user will get mail with auto generated password to login into portal and then he/she can change the password from his/her my account page password section.
Existed User Create Account Page in Liferay
Customer Expected Behavior of Create Account Page
Now assume we want create account page so that user can choose his/her own password at time of registration
The following are basic steps we should consider
Here our requirement is customize the existed liferay portal so best choice is hook plugins.
We have many kind of hook plugins so first we need to check with any portal property that can full fill out requirement.
Need to search in liferay-hook_6_x_x.dtd for appropriate portal property that can solve our problem.
If we find relevant portal property then we will choose portal properties hook Plugin to implement it otherwise we should go for other type of hook Plugin.
In our case “login.create.account.allow.custom.password” is full fill our requirement. “login.create.account.allow.custom.password” is portal property that will allow user to choose custom password at the time of registration means it will accommodate two more user input fields in the create account page.
Implement Solution using Portal Properties Hook
Direct Steps
Step:1
Create Liferay Hook Project using below Article
Liferay Hook Plugin Development with Liferay IDE
Step:2
Configure portal properties file name in “liferay-hook.xml” its in hook Plugin WEB-INF directory (/Sample-hook/docroot/WEB-INF/liferay-hook.xml)
Add following configuration in “liferay-hook.xml
<hook>
<portal-properties>portal.properties</portal-properties>
</hook>
Step:3
Create “portal.properites” file in Plugin Hook src directory (/Sample-hook/docroot/WEB-INF/src/portal.properties)
Step:4
Add overridden property name and its value in “portal.properites” file that is Plugin Hook src directory and possible overridden portal properties are available in “liferay-hook_6_x_x.dtd”
Add Overridden Portal Property in hook “portal.properties” files as follows
login.create.account.allow.custom.password=true
Step:5
Once we done all above steps deploy the Hook Plugin by double click on deploy target in the ANT view of eclipse or you can use “ant deploy” target from command prompt.
Once Portal Properties Hook Plugin successfully deployed ,now go to create account page then you can see password fileds in the page
The following screen shows you password filed
Crete Portal properties Hook using Liferay IDE Graphical User Interface
First we need to create Liferay Hook Plugin please follow the article and Create liferay hook Plugin
Liferay Hook Plugin Development with Liferay IDE
Now select the created hook Plugin in the project explorer
Go to File--> New Liferay Hook Configuration
now you can see dialog window select portal properties check box then click on next
Now you can see another dialog there you can see two sections in the bottom section is for adding portal properties. Now click on Add button
Now you will get another window there you can see property name and value input fields . For property name you can see “select” button
Now click on “select” button it will show another dialog to select possible portal properties.
Choose required property then click on OK
Now selected property will be appear in the property filed and enter appropriate values for the property in the values filed.
Click the OK and finally click on the Finish button. Now the portal properties file will be created in the hook src directory (“/Sample-hook/docroot/WEB-INF/src/portal.properties”).
The overridden properties and values are present in the “portal.properties” file
Overriding More Portal Properties
In the project explored go to /Sample-hook/docroot/WEB-INF and double click on “liferay-hook.xml” file then it will be open in editor and we have two views “source” view and “overview”, default view is “overview”
The following is “overview” of “liferay-hook.xml”
Note:
All hook related configuration are placed in “liferay-hook.xml”
In the “overview” you can find “Portal properties” icon with text ,click on that and check the “Customize Liferay Portal Properties” As soon as you check the box then you can see “portal properties” input field and “portal properties overrides” that can have two sections “Name” and “Value”
The following screen show you required input fields
Now we can see Add icon(+) click on Add icon then you can see Name and Value fields in the bottom of “Portal Properties Overrides” input field.
Now in the name field you can see browse button. You can click on browse button then you can see dialog window there you can see all possible portal properties that can be overridden and you can have search field to search properties.
Now select required property and click on OK then it will be appear in the “Override Name” field and enter appropriate value in “Override Value” field
If we want we can also add more values or you can remove values using Add and Remove icons.
Once we done then save the file (Ctrl+S).
In the source view you can see the “liferay-hook.xml” as follows
Ass soon as we save the file then portal property name and overridden value will be written in “portal.proerties” file that is in hook Plugin src directory
Once we done all above steps deploy the Hook Plugin by double click on deploy target in the ANT view of eclipse or you can use “ant deploy” target from command prompt.
Once Portal Properties Hook Plugin successfully deployed then you can see respective changes in the liferay portal.
The following are possible portal properties that we can override using hook plugins
admin.default.group.names
admin.default.role.names
admin.default.user.group.names
asset.publisher.asset.entry.query.processors
asset.publisher.display.styles
asset.publisher.query.form.configuration
auth.forward.by.last.path
auth.public.paths
auto.deploy.listeners
application.startup.events
auth.failure
auth.max.failures
auth.token.ignore.actions
auth.token.ignore.portlets
auth.token.impl
auth.pipeline.post
auth.pipeline.pre
auto.login.hooks
captcha.check.portal.create_account
captcha.engine.impl
com.liferay.portal.servlet.filters.*Filter
company.default.locale
company.default.time.zone
company.settings.form.authentication
company.settings.form.configuration
company.settings.form.identification
company.settings.form.miscellaneous
control.panel.entry.class.default
convert.processes
default.landing.page.path
default.regular.color.scheme.id
default.regular.theme.id
default.wap.color.scheme.id
default.wap.theme.id
dl.file.entry.drafts.enabled
dl.file.entry.processors
dl.repository.impl
dl.store.antivirus.impl
dl.store.impl
dockbar.add.portlets
field.enable.com.liferay.portal.model.Contact.birthday
field.enable.com.liferay.portal.model.Contact.male
field.enable.com.liferay.portal.model.Organization.status
hot.deploy.listeners
javascript.fast.load
journal.article.form.add
journal.article.form.translate
journal.article.form.update
layout.form.add
layout.form.update
layout.set.form.update
layout.static.portlets.all
layout.template.cache.enabled
layout.types
layout.user.private.layouts.auto.create
layout.user.private.layouts.enabled
layout.user.private.layouts.power.user.required
layout.user.public.layouts.auto.create
layout.user.public.layouts.enabled
layout.user.public.layouts.power.user.required
ldap.attrs.transformer.impl
locales
locales.beta
locales.enabled
lock.listeners
login.create.account.allow.custom.password
login.events.post
login.events.pre
login.form.navigation.post
login.form.navigation.pre
logout.events.post
logout.events.pre
mail.hook.impl
my.sites.show.private.sites.with.no.layouts
my.sites.show.public.sites.with.no.layouts
my.sites.show.user.private.sites.with.no.layouts
my.sites.show.user.public.sites.with.no.layouts
organizations.form.add.identification
organizations.form.add.main
organizations.form.add.miscellaneous
passwords.passwordpolicytoolkit.generator
passwords.passwordpolicytoolkit.static
passwords.toolkit
phone.number.format.impl
phone.number.format.international.regexp
phone.number.format.usa.regexp
portlet.add.default.resource.check.enabled
portlet.add.default.resource.check.whitelist
portlet.add.default.resource.check.whitelist.actions
rss.feeds.enabled
sanitizer.impl
servlet.session.create.events
servlet.session.destroy.events
servlet.service.events.post
servlet.service.events.pre
session.max.allowed
session.phishing.protected.attributes
session.store.password
sites.form.add.advanced
sites.form.add.main
sites.form.add.seo
sites.form.update.advanced
sites.form.update.main
sites.form.update.seo
social.activity.sets.bundling.enabled
social.activity.sets.enabled
social.activity.sets.selector
social.bookmark.*
terms.of.use.required
theme.css.fast.load
theme.images.fast.load
theme.jsp.override.enabled
theme.loader.new.theme.id.on.import
theme.portlet.decorate.default
theme.portlet.sharing.default
theme.shortcut.icon
time.zones
upgrade.processes
user.notification.event.confirmation.enabled
users.email.address.generator
users.email.address.required
users.email.address.validator
users.form.add.identification
users.form.add.main
users.form.add.miscellaneous
users.form.my.account.identification
users.form.my.account.main
users.form.my.account.miscellaneous
users.form.update.identification
users.form.update.main
users.form.update.miscellaneous
users.full.name.generator
users.full.name.validator
users.image.max.height
users.image.max.width
users.screen.name.always.autogenerate
users.screen.name.generator
users.screen.name.validator
value.object.listener.*
Author
0 comments:
Post a Comment