Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Charles de Courval
Setting up FriendlyURl, How do I do it ?
October 8, 2010 12:15 PM
Answer

Charles de Courval

Rank: Junior Member

Posts: 55

Join Date: July 31, 2010

Recent Posts

Hi,
I've read lots of forum post, wiki docs and other peices of information on the web regarding FriendlyURL and as far as I can tell, it should be working out of the box.

Is there a configuration switch to turn the thing on ?

The configuration in liferay-portlet.xml for portlet 56 (journal content) is there and so is the routing file it points to. But I still get a URL looking like this when accessing a Web Content Display:
http://localhost:8080/home1?p_p_id=56_INSTANCE_mS24&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-2&p_p_col_count=1&page=2

I'm using liferay sdk 6.0.5 bundled with tomcat on a MySql db and I havn't made any changes to the liferay-portlet.xml and journal-content-friendly-url-routes.xml file.

Is there anybody outthere that can help ?
thanks
Charles
Felix Ashirov
RE: Setting up FriendlyURl, How do I do it ?
October 8, 2010 6:56 PM
Answer

Felix Ashirov

Rank: Regular Member

Posts: 128

Join Date: February 26, 2010

Recent Posts

Friendly URLs for a particular portlet are generated using method buildPath of the portlet's "friendly-url-mapper-class" (defined in liferay-portlet.xml) in case you are using "<liferay-portlet:renderURL>" tag:

1<liferay-portlet:renderURL plid="11103" portletName="101_INSTANCE_qas2" var="itemURL">
2      <liferay-portlet:param name="assetId" value="14418"/>
3      <liferay-portlet:param name="struts_action" value="/asset_publisher/view_content"/>
4      <liferay-portlet:param name="redirect" value="<%=currentURL%>"/>
5</liferay-portlet:renderURL>


However, not all portlets have friendly url mapper class. The Journal Content portlet does not have one.
Check out Liferay builtin portlet's configuration file liferay-portlet.xml. Portlet able to use a friendly URL feature has a defined "friendly-url-mapper-class" property. For instance, "Asset Publisher" portlet uses com.liferay.portlet.assetpublisher.AssetPublisherFriendlyURLMapper class.
Charles de Courval
RE: Setting up FriendlyURl, How do I do it ?
October 12, 2010 3:50 AM
Answer

Charles de Courval

Rank: Junior Member

Posts: 55

Join Date: July 31, 2010

Recent Posts

Hi Felix, thanks for the reply, but as you'll see from the 2 bits of configuration from the liferay-portlet.xml, both of my portlet use the DefaultFriendlyURLMapper class as the mapper class. furthermore, the class you mentionned, AssetPublisherFriendlyURLMapper.class, is not part of of the distribution and the sourcecode for 6.0.5.

My journal content confirugation in liferay-portlet.xml
 1
 2<portlet>
 3  <portlet-name>56</portlet-name>
 4  <icon>/html/icons/journal_content.png</icon>
 5  <struts-path>journal_content</struts-path>
 6  <configuration-action-class>com.liferay.portlet.journalcontent.action.ConfigurationActionImpl</configuration-action-class>
 7  <friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
 8  <friendly-url-mapping>journal_content</friendly-url-mapping>
 9  <friendly-url-routes>com/liferay/portlet/journalcontent/journal-content-friendly-url-routes.xml</friendly-url-routes>
10  ....
11</portlet>


My asset publisher confirugation in liferay-portlet.xml
 1
 2<portlet>
 3  <portlet-name>101</portlet-name>
 4  <icon>/html/icons/asset_publisher.png</icon>
 5  <struts-path>asset_publisher</struts-path>
 6  <configuration-action-class>com.liferay.portlet.assetpublisher.action.ConfigurationActionImpl</configuration-action-class>
 7  <indexer-class>com.liferay.portlet.assetpublisher.util.AssetIndexer</indexer-class>
 8  <friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
 9  <friendly-url-mapping>asset_publisher</friendly-url-mapping>
10  <friendly-url-routes>com/liferay/portlet/assetpublisher/asset-publisher-friendly-url-routes.xml</friendly-url-routes>
11.....
12</portlet>


Any other idea ?
Felix Ashirov
RE: Setting up FriendlyURl, How do I do it ?
October 12, 2010 5:00 AM
Answer

Felix Ashirov

Rank: Regular Member

Posts: 128

Join Date: February 26, 2010

Recent Posts

Oh sorry!
My previos post was for Liferay 5.2.3.
However, what taglib do you use for portlet URL?
Charles de Courval
RE: Setting up FriendlyURl, How do I do it ?
October 12, 2010 5:34 AM
Answer

Charles de Courval

Rank: Junior Member

Posts: 55

Join Date: July 31, 2010

Recent Posts

I'm not using anything per say, jsute the out of the box implementation, adding some content and trying to have a descent friendly mapped URL.

Here's where I'm at this morning, I know that both file (liferay-portlet.xml and journal-content-friendly-url-routes.xml) are loaded and parsed. So what I'm looking as is are the route in the routes.xml right, or am I reading them wrong.

Here are the routes in journal-content-friendly-url-routes.xml
 1
 2<routes>
 3    <route>
 4        <pattern>/56/{groupId:\d+}/{articleId:\d+}</pattern>
 5        <implicit-parameter name="instanceId">0000</implicit-parameter>
 6        <implicit-parameter name="p_p_state">maximized</implicit-parameter>
 7        <implicit-parameter name="struts_action">/journal_content/view</implicit-parameter>
 8    </route>
 9    <route>
10        <pattern>/56/{groupId:\d+}/{articleId:\d+}/{templateId:\d+}</pattern>
11        <implicit-parameter name="instanceId">0000</implicit-parameter>
12        <implicit-parameter name="p_p_state">maximized</implicit-parameter>
13        <implicit-parameter name="struts_action">/journal_content/view</implicit-parameter>
14    </route>
15    <route>
16        <pattern>/{p_p_id}/{groupId:\d+}/{articleId:\d+}</pattern>
17        <implicit-parameter name="struts_action">/journal_content/view</implicit-parameter>
18    </route>
19    <route>
20        <pattern>/{p_p_id}/{groupId:\d+}/{articleId:\d+}/{templateId:\d+}</pattern>
21        <implicit-parameter name="struts_action">/journal_content/view</implicit-parameter>
22    </route>
23</routes>


And here is the url that should be parsed:
http://localhost:8080/home1?p_p_id=56_INSTANCE_mS24&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-2&p_p_col_count=1&page=2

I shouldn't be seeing all the p_p_... parameters in the url.
Felix Ashirov
RE: Setting up FriendlyURl, How do I do it ?
October 12, 2010 6:53 AM
Answer

Felix Ashirov

Rank: Regular Member

Posts: 128

Join Date: February 26, 2010

Recent Posts

Liferay does not parse any portlet URLs, as far as know.
Friendly URLs are generated using Friendly URL Mapper class with buildPath method.

So if your URL is saved in source code "as is" it will not be parsed and converted to friendly URL.
Is that what you're trying to get?
Gaurang G
RE: Setting up FriendlyURl, How do I do it ?
February 2, 2011 5:49 AM
Answer

Gaurang G

Rank: New Member

Posts: 16

Join Date: April 28, 2010

Recent Posts

Hi Charles,

As I understand, it should work with
1http://localhost:8080/home1/-/56_INSTANCE_Yzz3/10226/10561

but I don't see the expected results, here it should try to place the article with id=10561 belonging to group=10226 into the web content display portlet=56_INSTANCE_Yzz3

I tried this by actually debugging the code and it isn't able to find articleId and groupId to render the article in the portlet.
So I tried it this way and it works.

1http://localhost:8080/home1/-/56_INSTANCE_Yzz3?groupId=10226&articleId=10561


Still digging into it more.
So as I understand the url's are to be generated in this format or may be customized more.
Gwowen Fu
RE: Setting up FriendlyURl, How do I do it ?
October 1, 2012 12:08 PM
Answer

Gwowen Fu

Rank: Expert

Posts: 301

Join Date: December 27, 2010

Recent Posts

The URL for Web Content Display:
http://localhost:8080/home1/-/journal_content/56_INSTANCE_Yzz3/10226/10561
Traolly Xiong
RE: Setting up FriendlyURl, How do I do it ?
November 11, 2014 6:20 AM
Answer

Traolly Xiong

Rank: Regular Member

Posts: 115

Join Date: December 30, 2011

Recent Posts

Hello Gwowen Fu,
Are there ways to get the Friendly URL for out of the box portlets such as "web content display portlet" or ways to customize Friendly URLs for them?
I see some documentation on generating FURLs for custom portlets, but not sure about out of the box portlets as of now.

Thanks.