Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
dennis monsewicz
VERY nasty URLS
August 5, 2009 1:52 PM
Answer

dennis monsewicz

Rank: Junior Member

Posts: 71

Join Date: May 28, 2009

Recent Posts

Why does liferay foobar URLs like they do? This makes it very difficult when developing applications (such as in PHP, ASP, RUBY, etc) to access nice url variables.

Normal Example of URL:
http://www.mysite.com/web/site/page?var=something

Liferay Example of URL:
http://www.liferay.com/web/guest/community/forums?p_p_id=19&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-2&p_p_col_count=1&_19_struts_action=%2Fmessage_boards%2Fedit_message&_19_redirect=%2Fweb%2Fguest%2Fcommunity%2Fforums%2F-%2Fmessage_boards%2Fcategory%2F239390&_19_categoryId=239390&_19_subject= (this was taken from my browser when posting this message)

Now I am developing a PHP app (portlet) I cannot navigate to a page using normal variable conventions

IE: http://www.mysite.com/web/site/page?var=something

I cannot write PHP code to $_GET the variable

PHP convention for grabbing URL variable:
$var = $_GET['var'];

The above DOES NOT work...

However if I place a link within my PHP portlet (and then liferay adds its gunky-ness to the url) I can access variables with this:

http://www.mysite.com/web/site/page?p_p_id=portletName_WAR_portletName&p_p_lifecycle=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-3&p_p_col_count=1&_portletName_WAR_portletName_phpURI=index.php?var=something

Now I can call the PHP convention of $_GET

IE: $var = $_GET['var'];

Can SOMEONE explain why Liferay adds this "gunky-ness" to the urls? Seems a bit of overkill and it looks HORRIBLE
Minhchau Dang
RE: VERY nasty URLS
August 5, 2009 8:08 PM
Answer

Minhchau Dang

LIFERAY STAFF

Rank: Expert

Posts: 349

Join Date: October 22, 2007

Recent Posts

If you're asking, "Why do all those parameters exist?" it starts with one concept -- you're working within a framework which allows for multiple web applications to co-exist on a single page. Namely, all the URL parameters you see either exist to provide additional flexibility (such as the ability to show a portlet on its own) or to provide standard, reusable ways to implement portlet features (such as edit/help modes and resource serving).

If you're looking to be minimalistic, as far as I know, the only parameter that's actually required is p_p_id, as that tells Liferay which portlet on a given page needs to know what's going on. The rest should be optional, though not using them means you lose out on the additional flexibilities those parameters provide, and you won't be able to leverage some of the out-of-the-box mechanisms that Liferay provides to implement common portlet features.

Why does Liferay include the optional parameters when building URLs, even when they're at their default values? Well, it doesn't do any harm to include them (except when it violates your sense of URL aesthetics), and it results in extra, unnecessary overhead to (a) check to see if you don't have to include them, and (b) re-initialize the parameters to their default values when the URL is read back in again by the application server.
dennis monsewicz
RE: VERY nasty URLS
August 6, 2009 7:51 AM
Answer

dennis monsewicz

Rank: Junior Member

Posts: 71

Join Date: May 28, 2009

Recent Posts

Hmmm... your post was VERY helpful. THANKS!

Here is a new question...

Is there anyway to have Liferay not "reinitalize" link params on <a></a> tags in a custom portlet?
dennis monsewicz
RE: VERY nasty URLS
August 17, 2009 12:38 PM
Answer

dennis monsewicz

Rank: Junior Member

Posts: 71

Join Date: May 28, 2009

Recent Posts

Can I get ANY help on this subject? It takes forever for simple posts to get answered...

All I am looking for is this:

If I create a custom PHP portlet and have an external link on the page (IE: <a href="http://www.google.com">Click Me</a>) Liferay adds all of this other crap to the link making that link inaccessible and then I cannot navigate away from the current page. If this CANNOT be done then even bother doing anything inside liferay?
Anonymous
RE: VERY nasty URLS
August 17, 2009 1:01 PM
Answer

Anonymous

here's a long shot ... try removing "http://" from your HREF attribute ... like
1<a href="www.google.com">Click Me</a>
Fuad Efendi
RE: VERY nasty URLS
August 17, 2009 1:03 PM
Answer

Fuad Efendi

Rank: Regular Member

Posts: 171

Join Date: April 5, 2007

Recent Posts

Very long URLs are probably common problem for all portals... Liferay provides FriendlyURLMapper...

BTW, I already have constant porblems with long URLs, even latest-greates Mozilla sometimes doesn't understand that, especially if we have in URL another extremely long parameter "backURL=......." - of course I can use POST instead of GET but it is different story...
dennis monsewicz
RE: VERY nasty URLS
August 17, 2009 1:04 PM
Answer

dennis monsewicz

Rank: Junior Member

Posts: 71

Join Date: May 28, 2009

Recent Posts

Thanks for the suggestion but it did not work emoticon
dennis monsewicz
RE: VERY nasty URLS
August 17, 2009 1:14 PM
Answer

dennis monsewicz

Rank: Junior Member

Posts: 71

Join Date: May 28, 2009

Recent Posts

so there is no way to add a regular link to a page? I know if you add a web content display on the page you can have a regular link but this should stand for portlets too!