RE: URL Parameter in Web Content

thumbnail
Jason Roscoe, modified 6 Years ago. Junior Member Posts: 84 Join Date: 10/23/08 Recent Posts

We are using Liferay DXP 7.0 and I was wondering if it is possible to have some web content on a page, that gets a URL parameter and appends that to a URL in our content.  For example, lets say we havea page that has the below web content on the page:

 

Click here to go to our partner site.

 

When you intially come to the page, you would come to it with a guid in the URL, like www.xyz.com?guid=12345.  In the web content above, I would like the "Click here" to be an actual link to another site (www.abc.com?guid=12345), and we pass the guid that was in our original page url.

Does anyone know how can this be done?

 

Thanks!

thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts

In the absense of a better way to do it, you could use the following code I think --

 

<#assign serviceContext = staticUtil["com.liferay.portal.kernel.service.ServiceContextThreadLocal"].getServiceContext()>
<#assign httpServletRequest = serviceContext.getRequest()/>

 

That will give you the real request object. From there you should be able to use the portalUtil to get the original request object, query string and all. Out of curiosiy though, how are you linking to the page? and how is the GUID determined? If it something that is consistent, then it might be better to use a service to pull it from storage rather than use the approach I listed above.