NOTE: This article is an INTERNAL article and is not visible to customers, currently. Please only link this article in internal comments, but not public comments.
Issue
- Having a site Custom Field, such as:
Key: mysitecustomfield
On 6.2 EE, it was possible to get its value as per below:
Value: Hello From Site custom field!<#assign prop = layout.getExpandoBridge().getAttribute("mysitecustomfield") >
This, however, no longer works on DXP 7.2:ERROR [http-nio-8080-exec-11][runtime:59] Error executing FreeMarker template
FreeMarker template error:
Java method "com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl.getAttribute(String)" threw an exception when invoked on com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl object "com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl@184206bb"; see cause exception in the Java stack trace.
----
FTL stack trace ("~" means nesting-related):
- Failed at: #assign show_search = layout.getGroup... [in template "..._SERVLET_CONTEXT_/templates/init_custom.ftl" at line 24, column 1]
Environment
- Liferay DXP 7.1+
Resolution
- Use this code instead:
<#assign layout = themeDisplay.getLayout() />
<#assign site_custom_field = layout.getGroup().getExpandoBridge().getAttribute("mysitecustomfield") />
<h1>${mysitecustomfield}</h1>