legacy-knowledge-base
公開されました Sep. 10, 2025

DXP 7.2でFreemarkerでサイトのカスタムフィールド値を取得するには?

written-by

Alfonso Crisci

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

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

legacy-article

learn-legacy-article-disclaimer-text

問題

  • サイト カスタムフィールドを持つ、など。
    Key: mysitecustomfield
    Value: Hello From Site custom field!
    6.2EEでは、以下のように値を取得することができました。
    <#assign prop = layout.getExpandoBridge().getAttribute("mysitecustomfield") >
    しかし、これはもう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]

環境への配慮

  • Liferay DXP 7.1

決議

  • 代わりにこのコードを使用してください。
    <#assign layout = themeDisplay.getLayout() />
    <#assign site_custom_field = layout.getGroup().getExpandoBridge().getAttribute("mysitecustomfield") />
    <h1>${mysitecustomfield}</h1>

追加情報

did-this-article-resolve-your-issue

legacy-knowledge-base