Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Johny black
add friendly URL to blog
March 20, 2012 2:00 PM
Answer

Johny black

Rank: New Member

Posts: 20

Join Date: March 6, 2012

Recent Posts

I have liferay blog. When I click on the blog entry a detailed URL comes up. I'm trying to change the URL from something like this

http://localhost.super.com:8080/web/simpleblogs/home/-/blogs/johny-s-blog?_33_redirect=http%3A%2F%2Flocalhost.super.com%3A8080%2Fweb%2Fsimpleblogs%2Fhome%3Fp_p_id%3D33%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1

to something like this.

http://localhost.wm.com:8080/web/simpleblogs/home/-/blogs/johny-s-blog

Can this be done? I basically don't want any params showing up in the URL.
Juhi Kumari
RE: add friendly URL to blog
March 21, 2012 5:22 AM
Answer

Juhi Kumari

Rank: Expert

Posts: 347

Join Date: December 12, 2011

Recent Posts

Hi

You can achieve this using friendly url. See this wiki .
Hope it will useful for you.

Regards
Juhi
Johny black
RE: add friendly URL to blog
March 21, 2012 7:02 AM
Answer

Johny black

Rank: New Member

Posts: 20

Join Date: March 6, 2012

Recent Posts

Juhi Kumari:
Hi

You can achieve this using friendly url. See this wiki .
Hope it will useful for you.

Regards
Juhi



In this WIKI it says to modify

liferay-portlet.xml #

Here is an excerpt of /portal-web/docroot/WEB-INF/liferay-portlet.xml/


but I can't find portal-web under tomcat-7.0.23/webapps

Is the location different in 6.1? or am I looking in the wrong place?
Mayur Patel
RE: add friendly URL to blog
March 21, 2012 7:44 AM
Answer

Mayur Patel

Rank: Expert

Posts: 349

Join Date: November 17, 2010

Recent Posts

Johny, the location is different one , you've to do modification here,

\tomcat-6.0.32\webapps\ROOT\WEB-INF\liferay-portlet.xml\


Thanks
Johny black
RE: add friendly URL to blog
March 21, 2012 8:56 AM
Answer

Johny black

Rank: New Member

Posts: 20

Join Date: March 6, 2012

Recent Posts

Mayur Patel:
Johny, the location is different one , you've to do modification here,

\tomcat-6.0.32\webapps\ROOT\WEB-INF\liferay-portlet.xml\


Thanks



Thank you Mayur, I was able to find this file but now I have a new issue. I can't seem to find

<friendly-url-routes>com/liferay/portlet/blogs/blogs-friendly-url-routes.xml</friendly-url-routes>

blogs-friendly-url-routes.xml


Is this part of a JAR? if so do you know which one?
Mayur Patel
RE: add friendly URL to blog
March 21, 2012 9:15 AM
Answer

Mayur Patel

Rank: Expert

Posts: 349

Join Date: November 17, 2010

Recent Posts

Johny, you wanted to do it for Blogs portlet so look at <portlet-name>33</portlet-name> in liferay-portlet.xml

it contains entry which u r finding that is ,

<friendly-url-routes>com/liferay/portlet/blogs/blogs-friendly-url-routes.xml</friendly-url-routes>

and I'm checking same thing in Liferay 6.0E source, I'm not sure about Liferay 6.1E

Thanks
Johny black
RE: add friendly URL to blog
March 21, 2012 9:56 AM
Answer

Johny black

Rank: New Member

Posts: 20

Join Date: March 6, 2012

Recent Posts

Mayur Patel:
Johny, you wanted to do it for Blogs portlet so look at <portlet-name>33</portlet-name> in liferay-portlet.xml

it contains entry which u r finding that is ,

<friendly-url-routes>com/liferay/portlet/blogs/blogs-friendly-url-routes.xml</friendly-url-routes>

and I'm checking same thing in Liferay 6.0E source, I'm not sure about Liferay 6.1E

Thanks


My apologies. I meant to say that I cant find the file blogs-friendly-url-routes.xml.

This is the file I need to look into and make modifications in. Can you tell me where I can find this file (blogs-friendly-url-routes.xml)


Thanks.
Hitoshi Ozawa
RE: add friendly URL to blog
March 21, 2012 2:57 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

I meant to say that I cant find the file blogs-friendly-url-routes.xml.


That's in the following directory in Liferay's source code:
\portal-impl\src\com\liferay\portlet\blogs

When Liferay is build from the source, it'll be included in webapps\ROOT\WEB-INF\lib\portal-impl.jar
Johny black
RE: add friendly URL to blog
March 22, 2012 7:18 AM
Answer

Johny black

Rank: New Member

Posts: 20

Join Date: March 6, 2012

Recent Posts

Thanks Hitoshi, that is exactly what I was looking for.
Johny black
RE: add friendly URL to blog
March 22, 2012 2:10 PM
Answer

Johny black

Rank: New Member

Posts: 20

Join Date: March 6, 2012

Recent Posts

I'm running into an issue. I'm using Liferay 6.1 I have liferay blog portlet and trying to use Friendly URL but unsuccessful.
The info on the WIKI

http://www.liferay.com/web/connor.mckay/blog/-/blogs/5262286

It only states that to hide p_p_mode set it to normal Which I've done. I also tried
putting

<ignored-parameter name="p_p_lifecycle" />
<overridden-parameter name="p_p_lifecycle">1</overridden-parameter>

in my routes for /blogs/view and /blogs/view_entry struts action. Can someone tell me what I need to replace or delete so I don't see additonal p_p_ params

This is the original blogs-friendly-url-routes.xml

<?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">

<routes>
<route>
<pattern></pattern>
<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
<implicit-parameter name="p_p_state">normal</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/view</implicit-parameter>
</route>
<route>
<pattern>/maximized</pattern>
<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
<implicit-parameter name="p_p_state">maximized</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/view</implicit-parameter>
</route>
<route>
<pattern>/rss</pattern>
<ignored-parameter name="p_p_cacheability" />
<implicit-parameter name="p_p_lifecycle">2</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/rss</implicit-parameter>
</route>
<route>
<pattern>/trackback/{entryId:\d+}</pattern>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<implicit-parameter name="p_p_state">exclusive</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/trackback</implicit-parameter>
</route>
<route>
<pattern>/trackback/{entryId:\d+}/{p_p_state}</pattern>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/trackback</implicit-parameter>
</route>
<route>
<pattern>/trackback/{urlTitle}</pattern>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<implicit-parameter name="p_p_state">exclusive</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/trackback</implicit-parameter>
</route>
<route>
<pattern>/rss/{p_p_state}</pattern>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/rss</implicit-parameter>
</route>
<route>
<pattern>/trackback/{urlTitle}/{p_p_state}</pattern>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/trackback</implicit-parameter>
</route>
<route>
<pattern>/{entryId:\d+}</pattern>
<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
<implicit-parameter name="p_p_state">normal</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/view_entry</implicit-parameter>
</route>
<route>
<pattern>/{entryId:\d+}/{p_p_state}</pattern>
<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/view_entry</implicit-parameter>
</route>
<route>
<pattern>/{urlTitle}</pattern>
<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
<implicit-parameter name="p_p_state">normal</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/view_entry</implicit-parameter>
</route>
<route>
<pattern>/{urlTitle}/{p_p_state}</pattern>
<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
<implicit-parameter name="struts_action">/blogs/view_entry</implicit-parameter>
</route>
</routes>
Mayur Patel
RE: add friendly URL to blog
March 23, 2012 7:40 AM
Answer

Mayur Patel

Rank: Expert

Posts: 349

Join Date: November 17, 2010

Recent Posts

Hi Johny,

Routes support two advanced features that make them even more flexible. The ignored-parameter option forces a parameter to never be shown in the query string. The overridden-parameter options always sets a parameter to the given value when a URL is parsed, but does not set any requirements on the contents of the portlet URL parameters when a URL is generated.


you can remove same by using ignored-parameter in matching routes in your case that is for /blogs/view and /blogs/view_entry.

for ex.
<ignored-parameter name="p_p_col_id" />
<ignored-parameter name="p_p_col_count" />
<ignored-parameter name="p_p_mode" />
<ignored-parameter name="p_p_state" />
<ignored-parameter name="p_p_lifecycle" />


you can add something like below for adding additional attributes if you want,

1<route>
2<pattern>/{parm1}</pattern>
3<generated-parameter name="parm1">/{parm1}</generated-parameter>
4</route>


Below link may give you some idea,
http://www.liferay.com/community/forums/-/message_boards/message/8177475

Thanks
Florencia Gadea
RE: add friendly URL to blog
March 27, 2012 11:22 AM
Answer

Florencia Gadea

Rank: Regular Member

Posts: 146

Join Date: March 27, 2012

Recent Posts

Hi Johny,

You have to replace the blogs-friendly-url-routes.xml file with this one:

 1
 2<?xml version="1.0"?>
 3<!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">
 4
 5<routes>
 6    <route>
 7        <pattern></pattern>
 8        <ignored-parameter name="redirect"/>
 9        <implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
10        <implicit-parameter name="p_p_state">normal</implicit-parameter>
11        <implicit-parameter name="struts_action">/blogs/view</implicit-parameter>
12    </route>
13    <route>
14        <pattern>/maximized</pattern>
15        <ignored-parameter name="redirect"/>
16        <implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
17        <implicit-parameter name="p_p_state">maximized</implicit-parameter>
18        <implicit-parameter name="struts_action">/blogs/view</implicit-parameter>
19    </route>
20    <route>
21        <pattern>/rss</pattern>
22        <ignored-parameter name="redirect"/>
23        <ignored-parameter name="p_p_cacheability" />
24        <implicit-parameter name="p_p_lifecycle">2</implicit-parameter>
25        <implicit-parameter name="struts_action">/blogs/rss</implicit-parameter>
26    </route>
27    <route>
28        <pattern>/trackback/{entryId:\d+}</pattern>
29        <ignored-parameter name="redirect"/>
30        <implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
31        <implicit-parameter name="p_p_state">exclusive</implicit-parameter>
32        <implicit-parameter name="struts_action">/blogs/trackback</implicit-parameter>
33    </route>
34    <route>
35        <pattern>/trackback/{entryId:\d+}/{p_p_state}</pattern>
36        <ignored-parameter name="redirect"/>
37        <implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
38        <implicit-parameter name="struts_action">/blogs/trackback</implicit-parameter>
39    </route>
40    <route>
41        <pattern>/trackback/{urlTitle}</pattern>
42        <ignored-parameter name="redirect"/>
43        <implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
44        <implicit-parameter name="p_p_state">exclusive</implicit-parameter>
45        <implicit-parameter name="struts_action">/blogs/trackback</implicit-parameter>
46    </route>
47    <route>
48        <pattern>/rss/{p_p_state}</pattern>
49        <ignored-parameter name="redirect"/>
50        <implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
51        <implicit-parameter name="struts_action">/blogs/rss</implicit-parameter>
52    </route>
53    <route>
54        <pattern>/trackback/{urlTitle}/{p_p_state}</pattern>
55        <ignored-parameter name="redirect"/>
56        <implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
57        <implicit-parameter name="struts_action">/blogs/trackback</implicit-parameter>
58    </route>
59    <route>
60        <pattern>/{entryId:\d+}</pattern>
61        <ignored-parameter name="redirect"/>
62        <implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
63        <implicit-parameter name="p_p_state">normal</implicit-parameter>
64        <implicit-parameter name="struts_action">/blogs/view_entry</implicit-parameter>
65    </route>
66    <route>
67        <pattern>/{entryId:\d+}/{p_p_state}</pattern>
68        <ignored-parameter name="redirect"/>
69        <implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
70        <implicit-parameter name="struts_action">/blogs/view_entry</implicit-parameter>
71    </route>
72    <route>
73        <pattern>/{urlTitle}</pattern>
74        <ignored-parameter name="redirect"/>
75        <implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
76        <implicit-parameter name="p_p_state">normal</implicit-parameter>
77        <implicit-parameter name="struts_action">/blogs/view_entry</implicit-parameter>
78    </route>
79    <route>
80        <pattern>/{urlTitle}/{p_p_state}</pattern>
81        <ignored-parameter name="redirect"/>
82        <implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
83        <implicit-parameter name="struts_action">/blogs/view_entry</implicit-parameter>
84    </route>
85</routes>


And your url will look just the way you want.
Bella fernandis
RE: add friendly URL to blog
February 5, 2013 11:11 PM
Answer

Bella fernandis

Rank: New Member

Posts: 15

Join Date: November 5, 2012

Recent Posts

Thanks Florencia Gadea for your help. I successfully updated the url to localhost:8080/blog/-/blogs/testing. But what if i want to remove the "-" from the url??
I want the url to be localhost:8080/blog/blogs/testing. Can you please help me with this??
Xav NYC
RE: add friendly URL to blog
March 23, 2013 6:52 AM
Answer

Xav NYC

Rank: New Member

Posts: 23

Join Date: September 27, 2012

Recent Posts

Hi,

I want to make sure I understand it properly.
Does this mean that to activate friendly urls for standard liferay portlets we have to modify an xml configuration file embedded in portal-imlp.jar?
Sounds like a bit of a pain for something that I'm sure most people want to do.
It would make more sense in my opinion to have the friendly-url-routes.xml files reside outside the jar.

X.
Xav NYC
RE: add friendly URL to blog
March 23, 2013 8:09 AM
Answer

Xav NYC

Rank: New Member

Posts: 23

Join Date: September 27, 2012

Recent Posts

Hi,

I managed to change the xxx-friendly-url-routes.xml for blogs and wiki and it works.
However I'm struggling now with document-library-display-friendly-url-routes.xml
What should I put in the file to have a friendly url?

How about the other main portlets, like asset publisher, journal content, et.c
Does anyone have a set of working xxx-friendly-url-routes.xml files for Liferay 6.1?

Thanks in advance.
X.
Naga Surya Dhanunjaya Rao Sriapthy
RE: add friendly URL to blog
April 3, 2013 11:01 AM
Answer

Naga Surya Dhanunjaya Rao Sriapthy

Rank: New Member

Posts: 14

Join Date: April 25, 2009

Recent Posts

Hi,

Is there any way to do hot deploy these changes of blogs-friendly-url-routes.xml instead of changing in portal-impl or ext-impl?

Thanks in advance.

Dhanunjay.
Tina Agrawal
RE: add friendly URL to blog
November 14, 2015 8:57 AM
Answer

Tina Agrawal

Rank: Expert

Posts: 294

Join Date: January 2, 2008

Recent Posts

Hi Florencia,

I have done exactly the same thing using ext plugin and also tried changing it directly in portal-impl.jar but nothing seems to work.
Restarted the server couple of times. Not sure what could be the issue.

Any suggestions.

Tina