Forums de discussion

Seeking currentURL in CMS template

Robert Berndt, modifié il y a 6 années.

Seeking currentURL in CMS template

New Member Publications: 4 Date d'inscription: 24/06/14 Publications récentes
I have set
journal.template.velocity.restricted.variables=
velocity.engine.restricted.variables=
in the portal-ext.properties.

Trying to get the current URL from within a CMS template. The following code retrieves nothing:

#set ($current_complete_url = $request.get("attributes").CURRENT_COMPLETE_URL)
#set ($current_url = $request.get("attributes").CURRENT_URL)

<p>Current URL : $current_url</p>
<p>Current Complete URL : $current_complete_url</p>

Is the $request parameter not available? Do I have the correct properties?

Liferay 6.1 enterprise
thumbnail
Amos Fong, modifié il y a 6 années.

RE: Seeking currentURL in CMS template

Liferay Legend Publications: 2047 Date d'inscription: 07/10/08 Publications récentes
Try just outputting $request first so you can see everything it has.

<p>Request: $request</p>

attributes should be in there, so then do $request.get("attributes") to narrow it down. Then I think it should be in there as CURRENT_URL: $request.get("attributes").get("CURRENT_URL").
Robert Berndt, modifié il y a 6 années.

RE: Seeking currentURL in CMS template

New Member Publications: 4 Date d'inscription: 24/06/14 Publications récentes
I've tried that. I just prints the literal string:
$request.get("attributes")

If I output $request as "request: $request"I get the string:
request: {}

I'm sure this is a simple detail I'm missing. I'm leaning toward a system setting that makes the parameters available to the CMS templates, but the two property settings I've tried are not working.
thumbnail
Danielle Ardon, modifié il y a 6 années.

RE: Seeking currentURL in CMS template

Junior Member Publications: 37 Date d'inscription: 06/06/16 Publications récentes
Hey Robert, which 6.1 version are you using?

When I print $request in my velocity template with the same portal-ext.properties it does display a complete list of everything. I am using 6.1 ee ga3 sp5 with patch portal-60-6130.

I found some LPE/LPS tickets describing your problem:
https://issues.liferay.com/browse/LPS-32074
https://issues.liferay.com/browse/LPS-32074


perhaps you need a newer fixpack or something?