Tuesday 18 February 2014

Liferay Friendly URL with Action method call

Hi All,

Liferay comes with Friendly URL which reduce unwanted parameter in  URL and  display small  and good URL compare to action and render URL.

Now suppose you want to display News for Mobile device and you want to create friendly URL related it and you want also one action method with this friendly URL. So please follow steps.

1. open your liferay-porltet.xml file of  your portlet and write below line after <icon></icon> tag.

   <friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-  url-mapper-class>
    <friendly-url-mapping>mobile</friendly-url-mapping>
    <friendly-url-routes>com/portal/mobile-routes.xml</friendly-url-routes>


2.  Now create  mobile-routes.xml in relevant path in your portlet.

3.  Open mobile-routes.xml file and add below content.

     
<?xml version="1.0"?>
<!DOCTYPE routes PUBLIC "-//Liferay//DTD Friendly URL Routes 6.1.0//EN"
"http://www.liferay.com/dtd/liferay-friendly-url-routes_6_1_0.dtd">