Showing posts with label Liferay Hooks. Show all posts
Showing posts with label Liferay Hooks. Show all posts

Wednesday, May 11, 2011

Adding language selection portlet to the Dockbar using custom jsp hook plugin

The Liferay Language portlet provide an option to select from different localizations. It’s a common requirement in web application to display language selection option as flags in the header area.

In Liferay we can accomplish this through hook plugin as following:

1. Create a Liferay hook plugin project create sample-hook "Sample Dockbar Hook"

2. In the /docroot/WEB-INF/ folder open liferay-hook.xml file and add the following entry

<hook>

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

</hook>

3. Copy ${PORTAL_ROOT_HOME}htmlportletdockbarview.jsp to ${liferay.plugins.sdk}sample-hookdocrootWEB-INFjspshtmlportletdockbar folder.

4. Add the following code after Toggle Edit Control

<liferay-ui:language displayStyle="0" languageIds='<%= new string[] {"en_US","nl_NL"} %>' />

This will add English and Dutch Language to the dockbar.

5. Build and package the hook WAR file and deploy it on your Liferay server.