Fórum
how to get current url in template using freemarker in liferay
Dayanand Tiwari, modificado 6 Anos atrás.
how to get current url in template using freemarker in liferay
Junior Member Postagens: 91 Data de Entrada: 25/05/17 Postagens Recentes
how to get current url in template using freemarker in liferay.
I have tried multiple things but getting errors. Can anyone please provide me that working code to get the current url in template.
Mainly I have to compare where this url contains a particular string or not in my application.
I have tried multiple things but getting errors. Can anyone please provide me that working code to get the current url in template.
Mainly I have to compare where this url contains a particular string or not in my application.
Massimo Bevilacqua, modificado 6 Anos atrás.
RE: how to get current url in template using freemarker in liferay
Regular Member Postagens: 210 Data de Entrada: 27/12/16 Postagens Recentes
Hi,
try this:
In order to use "staticUtil" you must delete the variable restiriction
(this is for liferay 7, if you are using liferay 6 use "com.liferay.portal.service.ServiceContextThreadLocal")
try this:
In order to use "staticUtil" you must delete the variable restiriction
<#assign serviceContext = staticUtil["com.liferay.portal.kernel.service.ServiceContextThreadLocal"].getServiceContext()>
<#assign themeDisplay = serviceContext.getThemeDisplay() />
<div id="CurrentUrl">
CurrentURL: <#assign currentUrl = themeDisplay.getPortalURL() + themeDisplay.getURLCurrent() />
${currentUrl}
</div>
<#if currentUrl?contains("yourString")>
It contains "yourString"
<#else>
It doesn't 'contains "yourString"
<!--#if-->
(this is for liferay 7, if you are using liferay 6 use "com.liferay.portal.service.ServiceContextThreadLocal")
Dayanand Tiwari, modificado 6 Anos atrás.
RE: how to get current url in template using freemarker in liferay
Junior Member Postagens: 91 Data de Entrada: 25/05/17 Postagens Recentes
It fails in the first line saying evoluated to null or missing..and i think themeDisplay object also not available in template script.
Massimo Bevilacqua, modificado 6 Anos atrás.
RE: how to get current url in template using freemarker in liferay
Regular Member Postagens: 210 Data de Entrada: 27/12/16 Postagens Recentes
It works,
maybe you missed this
or this:
A server restart it could be necessary.
ThemeDisplay is available retrived in this way.
You will find below the output of the previously code pasted in a simple template
maybe you missed this
In order to use "staticUtil" you must delete the variable restiriction
or this:
(this is for liferay 7, if you are using liferay 6 use "com.liferay.portal.service.ServiceContextThreadLocal")
A server restart it could be necessary.
ThemeDisplay is available retrived in this way.
You will find below the output of the previously code pasted in a simple template
Goran Marinkovic, modificado 5 Anos atrás.
RE: how to get current url in template using freemarker in liferay
New Member Postagens: 12 Data de Entrada: 27/03/18 Postagens Recentes
if your url bla bla like: web-serbia/gest/organization
I
<h1>${themeDisplay.getURLCurrent()}</h1> you get : web-serbia/gest/organization
II
<h2>${themeDisplay.getLayout().getFriendlyURL()}</h2> you get: /organization
III
<h3>${"${themeDisplay.getLayout().getFriendlyURL()}"?remove_beginning("/")}</h3> you get: organization
I
<h1>${themeDisplay.getURLCurrent()}</h1> you get : web-serbia/gest/organization
II
<h2>${themeDisplay.getLayout().getFriendlyURL()}</h2> you get: /organization
III
<h3>${"${themeDisplay.getLayout().getFriendlyURL()}"?remove_beginning("/")}</h3> you get: organization
Roshan Qureshi, modificado 4 Anos atrás.
RE: how to get current url in template using freemarker in liferay
Regular Member Postagens: 159 Data de Entrada: 24/08/10 Postagens Recentes
I have same web content on two pages. I used above but getting same url on both pages.
If I do any changes in template and try from the home page its giving me home page url
But when go to another page projects - it also gives home page url only.
If I again change something in template and visit first projects page -it gives me project url but after that home page also gives project url.
It seems some bug.
If I do any changes in template and try from the home page its giving me home page url
But when go to another page projects - it also gives home page url only.
If I again change something in template and visit first projects page -it gives me project url but after that home page also gives project url.
It seems some bug.