How to access custom page fields in a theme template

I would like to use custom fields to display some strings in a topic.

I created a custom "intro" field of type Textbox.

How do I access the data in the theme template (speed)?

Since there is no "introspection" that variables declare, it is very difficult for me to figure out how to get them. The documentation is far from being used on the topic of custom fields: - /

+3


source to share


3 answers


If you are defining a custom attribute on the page than you can use

$layout.getExpandoBridge().getAttribute("intro")

      




Also see the javadoc or source for com.liferay.portlet.expando.model.ExpandoBridge

+7


source


if you need to use in FTL template, in my case for menu navigation template



<#assign prop = navItem.getLayout (). getExpandoBridge (). getAttribute ("prop_name")>

+1


source


Work with me at Liferay 7+:

Create a custom field type "site", fill in the data in the site settings and use the theme in the template to call this data into the liferay theme:

If the VM file:

#set ($site_custom_field = $layout.getGroup().getExpandoBridge().getAttribute("site_custom_field_key"))
<h1>$site_custom_field</h1>

      

If the file is FTL:

<#assign site_custom_field = layout.getGroup().getExpandoBridge().getAttribute("site_custom_field_key")>
<h1>${site_custom_field}</h1>

      

Have a nice day!

+1


source







All Articles