Skip to content

Instantly share code, notes, and snippets.

@epgarcia
Last active January 11, 2022 16:54
Show Gist options
  • Save epgarcia/1af5ee795033ab010926d9b24e166ea8 to your computer and use it in GitHub Desktop.
Save epgarcia/1af5ee795033ab010926d9b24e166ea8 to your computer and use it in GitHub Desktop.
Freemarker sample to iterate the portletPreferences variable on a Liferay Application Display Template
<#--
portletPreferences: Represents the preferences of the application that are used to display content
through this template. Use the map API of the selected template language to get the values of the
preferences.
-->
<#if portletPreferences?has_content>
<h1>Portlet Preferences</h1>
<ul>
<#list portletPreferences?keys as key>
<#assign values = portletPreferences[key] />
<#if values?has_content>
<li>${key}:
<ul>
<#list values as value>
<li>${value}</li>
</#list>
</ul>
</li>
</#if>
</#list>
</ul>
</#if>
@70853n
Copy link

70853n commented Dec 14, 2017

This doesn't work due to freemarker.template.TemplateModelException: Getting the number of items or enumerating the items is not supported on this method+sequence (wrapper: f.e.b.SimpleMethodModel) value.

Edit
Ye, portletPreferences?keys returns a map of class members...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment