Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Brian Scott Schupbach
Search results URLs are a random page in the portal
July 23, 2012 2:57 PM
Answer

Brian Scott Schupbach

Rank: Expert

Posts: 329

Join Date: October 23, 2008

Recent Posts

I've embeded the search portlet into my theme and the search results URLs are extremely odd. I can click on results and it brings up the correct content. However, the URL is a random page on the portlet. Is there anyway to force the URL to be a specific search results page? or maybe the current page? Having the results open up a random page is odd behavior..

I have two instances and this is only happening in the second instance. No idea why that would matter but it's just how it is working..
Brian Scott Schupbach
RE: Search results URLs are a random page in the portal
July 24, 2012 12:22 PM
Answer

Brian Scott Schupbach

Rank: Expert

Posts: 329

Join Date: October 23, 2008

Recent Posts

I'm not sure what caused the error but I wrote a hook to fix it. Here is the code:

This is located at html/portlet/search/main_search_result_form.jsp . I'm not sure that this is the best solution but here is how I corrected it. I added this right before the first span tag. I'm using liferay 6.1

 1
 2/**********************************ADDED*****************************/
 3/*
 4For some reason the URLs of the results were going to a random page. I created a page called
 5search-results and am forcing the results to open here.  On the page I added an asset publisher and grabbed the asset publishers unique ID.  I appended this to the new URL using the variable p_p_auth.
 6
 7*/
 8HttpServletRequest httpReq = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));
 9if(httpReq.getRequestURL().toString().contains("SecondSiteInstanceURL.org")) {
10    int startOfQueryString = viewURL.lastIndexOf('?');
11    viewURL = "/search-results"+viewURL.substring(startOfQueryString,viewURL.length())+"p_p_auth=TP4E7eFdFLjQ";
12}
13/**********************************END ADDED*************************/