3
votes

I am trying get the "theme_display" in a Web Content Template (on Liferay Portal 6.2). But it does not work.

    #set($serviceContext = $portal.getClass().forName("com.liferay.portal.service.ServiceContextThreadLocal").getServiceContext())
    #set($httpServletRequest = $serviceContext.getRequest())
    #set($objThemeDisplay = $httpServletRequest.getAttribute("THEME_DISPLAY"))

$themeDisplay

$theme_display

$request.themeDisplay

$request.get("theme-display")

2
This page may be helpful.brandizzi
What errors are you getting?Do these variables display nothing in web content template,as theare available in velocity templatesShivam Aggarwal

2 Answers

2
votes

You can get the themeDisplay object in web content templates using ServiceContextThreadLocal like so:

Example using: Liferay DXP, freemarker, web content template:

<#assign
serviceContextThreadLocal = staticUtil["com.liferay.portal.kernel.service.ServiceContextThreadLocal"]
themeDisplay = serviceContextThreadLocal.getServiceContext().getThemeDisplay()
/>

You will need to ensure you have turned off the restricted variables for templates.

0
votes

themeDisplay object is not available in WC Templates. What do you need it for? Perhaps you can get the same information from Service Locator....

Regards.