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.

7 comments:

  1. Thanks for this very good howto. But can you tell how I can modify the my-places Dropdown-Menu? I want to have a separate button for each entry in the drop-down menu.

    Greetings
    Stephan

    ReplyDelete
  2. Great blog, how about links exchanging? Please contact me asap, Thanks.

    ReplyDelete
  3. On the first sentence it looks like it were correct but if you look closely i cant see the point of this!

    ReplyDelete
  4. What I think, the main point is how to add language portlet to dockbar as flag options.

    ReplyDelete
  5. i tried to get the RSSFeed but feed site shows me some xml errors...

    ReplyDelete
  6. Hi Leandra,

    First of all thanks for your interest in our blog. Are you using google chrome browser? There are some problems in using feeds with google chrome. We are trying to fix this issue. Please try again with Firefox.

    ReplyDelete
  7. Fixed the RSS feeds bug. Now you can get feeds from any browser...

    ReplyDelete