Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Pau Aza
Redirect some pages to the same content
June 9, 2014 8:03 AM
Answer

Pau Aza

Rank: New Member

Posts: 4

Join Date: May 6, 2014

Recent Posts

Hi all!

I'm new to Liferay and I'm developing a site where I want to show the same layout except one portlet for different URL's. I'll explain myself:

I've got a country list and, for every country, I want to show the same page but with different information.

In PHP and Java I can do www.myweb.com?country=france and I've got the parameter, but I want to do that this way: www.myweb.com/france

Is there any way I can achieve this without creating a page for every country? Because I have 20 - 30 countries and I wouldn't want to create 20 - 30 nearly equal pages.

Thanks in advance!! ^^
Manali Lalaji
RE: Redirect some pages to the same content
June 9, 2014 9:17 AM
Answer

Manali Lalaji

Rank: Expert

Posts: 362

Join Date: March 9, 2010

Recent Posts

Hi Pau,

As far as I understand your requirement, You can try following:

1. Create a page CountryInfo
2. Put your portlet on the page
3. In your portlet's render method, try to fetch Url parameter
 1
 2          HttpServletRequest convertReq = PortalUtil.getHttpServletRequest(portletRequest);
 3      HttpServletRequest originalReq = PortalUtil.getOriginalServletRequest(convertReq);
 4      String countryName= originalReq.getParameter("country");
 5           if(countryName.equalsIgnoreCase('France')){
 6               //Perform operation                  
 7           }else if(){
 8           }else{  // Default info
 9          }


You can also refer link

HTH!
Pau Aza
RE: Redirect some pages to the same content
June 10, 2014 3:11 AM
Answer

Pau Aza

Rank: New Member

Posts: 4

Join Date: May 6, 2014

Recent Posts

Thanks a lot Manali, that is nearly the soution I'm looking for, but I might have explained myself wrong.

What I want to achieve is that I want to access to the same page even if I enter some different countries:

www.myweb.com/france
www.myweb.com/spain
www.myweb.com/portugal
...

Is there any way I can access all those URL and passing through the same Liferay page but changing the portlet's content?
Subhash Pavuskar
RE: Redirect some pages to the same content
June 10, 2014 3:56 AM
Answer

Subhash Pavuskar

Rank: Regular Member

Posts: 234

Join Date: March 12, 2012

Recent Posts

Hi,

Your question still not clear !! well as i understood by above i found like this
Create the Page Country instead of france,spain,portugal and you can pass the content dynamically .
Sorry if i am wrong or you can provide an clear example for the same.
Pau Aza
RE: Redirect some pages to the same content
June 10, 2014 4:04 AM
Answer

Pau Aza

Rank: New Member

Posts: 4

Join Date: May 6, 2014

Recent Posts

You were right, it is exactly what am I pretending to implement, but I don't know if it is possible to achieve that.
Subhash Pavuskar
RE: Redirect some pages to the same content
June 10, 2014 4:07 AM
Answer

Subhash Pavuskar

Rank: Regular Member

Posts: 234

Join Date: March 12, 2012

Recent Posts

Why it not possible !! What information you want to display whether of type WebContent Display or custom Porlet etc..?
Pau Aza
RE: Redirect some pages to the same content
June 16, 2014 7:45 AM
Answer

Pau Aza

Rank: New Member

Posts: 4

Join Date: May 6, 2014

Recent Posts

I've found a solution to my problem!

After days of searching I've found that, with a hook, I can achieve what I was pretending to do.

With my hook I can see when I'm trying to enter to a concrete country and then I redirect to a general page where I have a portlet that displays the information of that concrete country.

Many thanks to all for your help!! ^^

Pau