留言板

How to obtain the real current url?

Diego Figueroa,修改在13 年前。

How to obtain the real current url?

Junior Member 帖子: 38 加入日期: 10-3-11 最近的帖子
Hi all,

I have a portlet and I am trying to get the current url with:

String currentURL = PortalUtil.getCurrentURL(request);

My current url is something like:

http://mysite.com/user/diego/3/....

however using the getCurrentURL() method above I get something like:

/c/portal/layout?p_l_id=3071616

instead of:

/user/diego/3

Is there another method that returns this more friendly URL?

Thanks all!

Diego.
Mazhar Anwar,修改在13 年前。

RE: How to obtain the real current url?

Regular Member 帖子: 125 加入日期: 10-2-5 最近的帖子
I think you can try themeDisplay.getURLCurrent() method. Please check the signature in ThemeDisplay.java of portal source.

Regards,
thumbnail
Sandeep Nair,修改在13 年前。

RE: How to obtain the real current url?

Liferay Legend 帖子: 1744 加入日期: 08-11-6 最近的帖子
Hi,

Try doing this

themeDisplay.getLayout().getFriendlyURL();

Regards,
Sandeep
thumbnail
KK rajput,修改在13 年前。

RE: How to obtain the real current url?

Expert 帖子: 266 加入日期: 08-4-10 最近的帖子
Hi ,
are you using ext environment use this
PortletURL url = PortletURLUtil.getCurrent(PortletRequest preq, MimeResponse mimeResponse or RenderResponse renderResponse)

Thanks
KamalKant
Diego Figueroa,修改在13 年前。

RE: How to obtain the real current url?

Junior Member 帖子: 38 加入日期: 10-3-11 最近的帖子
Thank you all for your input.

I found the solution I wanted thanks to your information:

PortalUtil.getLayoutURL(themeDisplay.getLayout(),themeDisplay);

This gives me the complete URL that I wanted
thumbnail
Umer Sayeed,修改在10 年前。

RE: How to obtain the real current url?

Junior Member 帖子: 51 加入日期: 12-8-8 最近的帖子
String currentURL = PortletURLUtil.getCurrent(renderRequest, renderResponse).toString();
thumbnail
Vilmos Papp,修改在10 年前。

RE: How to obtain the real current url?

Liferay Master 帖子: 529 加入日期: 10-10-21 最近的帖子

String currentCompleteUrl = PortalUtil.getCurrentCompleteURL(request);
thumbnail
Goran Marinkovic,修改在5 年前。

RE: How to obtain the real current url? on Serbian Way

New Member 帖子: 12 加入日期: 18-3-27 最近的帖子
"Serbian way"

Make assign>
<#assign yy = '${"${themeDisplay.getLayout().getFriendlyURL()}"?remove_beginning("/")}' />

and somewhere in loop , maybe, use this assign like:
<#if entry?contains (yy)>

or just a print this variable>

<h3>${yy}</h3>

Explanation, if your url is like : web/guest/page1
You can get with : ${themeDisplay.getLayout().getFriendlyURL()} , this: /page1
and when We cut the "/" with ?remove_beginning("/"), will be only : page1