掲示板

Setting up FriendlyURl, How do I do it ?

thumbnail
13年前 に charles de courval によって更新されました。

Setting up FriendlyURl, How do I do it ?

Junior Member 投稿: 55 参加年月日: 10/07/31 最新の投稿
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
thumbnail
13年前 に Felix Ashirov によって更新されました。

RE: Setting up FriendlyURl, How do I do it ?

Regular Member 投稿: 128 参加年月日: 10/02/26 最新の投稿
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:

<liferay-portlet:renderurl plid="11103" portletname="101_INSTANCE_qas2" var="itemURL">
      <liferay-portlet:param name="assetId" value="14418" />
      <liferay-portlet:param name="struts_action" value="/asset_publisher/view_content" />
      <liferay-portlet:param name="redirect" value="<%=currentURL%>" />
</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.
thumbnail
13年前 に charles de courval によって更新されました。

RE: Setting up FriendlyURl, How do I do it ?

Junior Member 投稿: 55 参加年月日: 10/07/31 最新の投稿
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

<portlet>
  <portlet-name>56</portlet-name>
  <icon>/html/icons/journal_content.png</icon>
  <struts-path>journal_content</struts-path>
  <configuration-action-class>com.liferay.portlet.journalcontent.action.ConfigurationActionImpl</configuration-action-class>
  <friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
  <friendly-url-mapping>journal_content</friendly-url-mapping>
  <friendly-url-routes>com/liferay/portlet/journalcontent/journal-content-friendly-url-routes.xml</friendly-url-routes>
  ....
</portlet>


My asset publisher confirugation in liferay-portlet.xml

<portlet>
  <portlet-name>101</portlet-name>
  <icon>/html/icons/asset_publisher.png</icon>
  <struts-path>asset_publisher</struts-path>
  <configuration-action-class>com.liferay.portlet.assetpublisher.action.ConfigurationActionImpl</configuration-action-class>
  <indexer-class>com.liferay.portlet.assetpublisher.util.AssetIndexer</indexer-class>
  <friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
  <friendly-url-mapping>asset_publisher</friendly-url-mapping>
  <friendly-url-routes>com/liferay/portlet/assetpublisher/asset-publisher-friendly-url-routes.xml</friendly-url-routes>
.....
</portlet>


Any other idea ?
thumbnail
13年前 に Felix Ashirov によって更新されました。

RE: Setting up FriendlyURl, How do I do it ?

Regular Member 投稿: 128 参加年月日: 10/02/26 最新の投稿
Oh sorry!
My previos post was for Liferay 5.2.3.
However, what taglib do you use for portlet URL?
thumbnail
13年前 に charles de courval によって更新されました。

RE: Setting up FriendlyURl, How do I do it ?

Junior Member 投稿: 55 参加年月日: 10/07/31 最新の投稿
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

<routes>
	<route>
		<pattern>/56/{groupId:\d+}/{articleId:\d+}</pattern>
		<implicit-parameter name="instanceId">0000</implicit-parameter>
		<implicit-parameter name="p_p_state">maximized</implicit-parameter>
		<implicit-parameter name="struts_action">/journal_content/view</implicit-parameter>
	</route>
	<route>
		<pattern>/56/{groupId:\d+}/{articleId:\d+}/{templateId:\d+}</pattern>
		<implicit-parameter name="instanceId">0000</implicit-parameter>
		<implicit-parameter name="p_p_state">maximized</implicit-parameter>
		<implicit-parameter name="struts_action">/journal_content/view</implicit-parameter>
	</route>
	<route>
		<pattern>/{p_p_id}/{groupId:\d+}/{articleId:\d+}</pattern>
		<implicit-parameter name="struts_action">/journal_content/view</implicit-parameter>
	</route>
	<route>
		<pattern>/{p_p_id}/{groupId:\d+}/{articleId:\d+}/{templateId:\d+}</pattern>
		<implicit-parameter name="struts_action">/journal_content/view</implicit-parameter>
	</route>
</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.
thumbnail
13年前 に Felix Ashirov によって更新されました。

RE: Setting up FriendlyURl, How do I do it ?

Regular Member 投稿: 128 参加年月日: 10/02/26 最新の投稿
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?
13年前 に Gaurang G によって更新されました。

RE: Setting up FriendlyURl, How do I do it ?

New Member 投稿: 16 参加年月日: 10/04/28 最新の投稿
Hi Charles,

As I understand, it should work with
http://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.

http://localhost:8080/home1/-/56_INSTANCE_Yzz3?groupId=10226&amp;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.
11年前 に Gwowen Fu によって更新されました。

RE: Setting up FriendlyURl, How do I do it ?

Expert 投稿: 315 参加年月日: 10/12/27 最新の投稿
The URL for Web Content Display:
http://localhost:8080/home1/-/journal_content/56_INSTANCE_Yzz3/10226/10561
9年前 に Traolly Xiong によって更新されました。

RE: Setting up FriendlyURl, How do I do it ?

Regular Member 投稿: 195 参加年月日: 11/12/30 最新の投稿
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.