Fórum
Portal Url in VM
Syed Umair, modificado 11 Anos atrás.
Portal Url in VM
Junior Member Postagens: 36 Data de Entrada: 11/10/12 Postagens Recentes
Hi,
I have developed a structure and template. Currently, I am using localhost:8080 in my template, but when I will deploy my web it should not be localhost. Can anyone suggest me how to get portal url in VM template.
I can get it in jsp using themeDisplay.getPortalURL(), but I dont know how to do it in VM.
Any valuable suggestion will be appreciated.
Umair
I have developed a structure and template. Currently, I am using localhost:8080 in my template, but when I will deploy my web it should not be localhost. Can anyone suggest me how to get portal url in VM template.
I can get it in jsp using themeDisplay.getPortalURL(), but I dont know how to do it in VM.
Any valuable suggestion will be appreciated.
Umair
Rishi Dev Gupta, modificado 11 Anos atrás.
RE: Portal Url in VM
Expert Postagens: 255 Data de Entrada: 23/11/08 Postagens Recentes
Check this link this might help you
http://content.liferay.com/4.3/misc/theme-api-4.3.0.html
http://content.liferay.com/4.3/misc/theme-api-4.3.0.html
Jitendra Rajput, modificado 11 Anos atrás.
RE: Portal Url in VM
Liferay Master Postagens: 875 Data de Entrada: 07/01/11 Postagens Recentes
Could you please try with below code .
#set ($portalUtil= $utiLocator.findUtil("com.liferay.portal.util.portalUtil"))
#set ($portalURL=$portalUtil.getPortalURL($themeDisplay))
$portalURL
Syed Umair, modificado 11 Anos atrás.
RE: Portal Url in VM (Resposta)
Junior Member Postagens: 36 Data de Entrada: 11/10/12 Postagens Recentes
Thnx, for your replies. I manage it to do it with
#set($companyLocalService = $serviceLocator.findService("com.liferay.portal.service.CompanyLocalService"))
#set($company = $companyLocalService.getCompany($company_id))
#set($portalURL = $company.getVirtualHostname())
Rishi Dev Gupta, modificado 11 Anos atrás.
RE: Portal Url in VM (Resposta)
Expert Postagens: 255 Data de Entrada: 23/11/08 Postagens Recentes
You do not need to define service variable to get company information. You will get the $company object by default in vm file, thus no need to make a database hit.
Also you will need to set the property accordingly in portal.properties, if you want to use service layer (as answered y you)
#
# Input a comma delimited list of variables which are restricted from the
# context in Velocity based Journal templates.
#
journal.template.velocity.restricted.variables=serviceLocator
Also you will need to set the property accordingly in portal.properties, if you want to use service layer (as answered y you)
#
# Input a comma delimited list of variables which are restricted from the
# context in Velocity based Journal templates.
#
journal.template.velocity.restricted.variables=serviceLocator
Syed Umair, modificado 11 Anos atrás.
RE: Portal Url in VM
Junior Member Postagens: 36 Data de Entrada: 11/10/12 Postagens RecentesRishi Dev Gupta:
You do not need to define service variable to get company information. You will get the $company object by default in vm file, thus no need to make a database hit.
I have tried the $company object and it works same. And it will certainly improve the performance.