Legacy Knowledge Base
Published Jul. 2, 2025

How to get a Site's custom field value with Freemarker on DXP 7.2?

Written By

Alfonso Crisci

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

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
    Value: Hello From Site custom field!
    On 6.2 EE, it was possible to get its value as per below:
    <#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>

Additional Information

Did this article resolve your issue ?

Legacy Knowledge Base