Liferay DXP defines several
macros in
FTL_Liferay.ftl
template
that you can use in your theme templates to include theme resources, standard
portlets, and more. Liferay DXP also exposes its taglibs as FreeMarker
macros. See each
taglib’s documentation
for more information on using the taglib in your FreeMarker templates. This
reference guide lists the available FreeMarker macros that Liferay DXP offers.
Macro | Parameters | Description | Example |
---|---|---|---|
breadcrumbs | default_preferences | Adds the Breadcrumbs portlet with optional preferences | <@liferay.breadcrumbs /> |
control_menu | N/A | Adds the Control Menu portlet | <@liferay.control_menu /> |
css | file_name | Adds an external stylesheet with the specified file name location | <@liferay.css file_name="${css_folder}/mycss.css"/> |
date | format | Prints the date in the current locale with the given format | <@liferay.date format="/yyyy/MM/dd/HH/" /> |
js | file_name | Adds an external JavaScript file with the specified file name source | <@liferay.js file_name="${javascript_folder}/myJs.js"/> |
language | key | Prints the specified language key in the current locale | <@liferay.language key="last-modified" /> |
language_format | arguments key | Formats the given language key with the specified arguments. For example, passing go-to-x as the key and Mars as the arguments prints Go to Mars. | <@liferay.language_format arguments="${site_name}" key="go-to-x" /> |
languages | default_preferences | Adds the Languages portlet with optional preferences | <@liferay.languages /> |
navigation_menu | default_preferences instance_id | Adds the Navigation Menu portlet with optional preferences and instance ID. | <@liferay.navigation_menu /> |
search | default_preferences | Adds the Search portlet with optional preferences | <@liferay.search /> |
search_bar | default_preferences | Adds the Search Bar portlet with optional preferences | <@liferay.search_bar /> |
user_personal_bar | N/A | Adds the User Personal Bar portlet | <@liferay.user_personal_bar /> |
A few reference examples are shown below.
Reference Examples
The example below includes a language key with the language
macro directive
along with its language key
parameter:
<@liferay.language key="powered-by" />
This example includes the Search portlet with its Portlet Decorator portlet preference set to barebone:
<@liferay.search default_preferences=
freeMarkerPortletPreferences.getPreferences(
"portletSetupPortletDecoratorId", "barebone"
)
/>
You can also pass multiple portlet preferences in an object, as shown in the example below for the Navigation Menu portlet:
<#assign secondaryNavigationPreferencesMap =
{
"displayStyle": "ddmTemplate_NAVBAR-BLANK-JUSTIFIED-FTL",
"portletSetupPortletDecoratorId": "barebone",
"rootLayoutType": "relative",
"siteNavigationMenuId": "0",
"siteNavigationMenuType": "1"
}
/>
<@liferay.navigation_menu
default_preferences=
freeMarkerPortletPreferences.getPreferences(secondaryNavigationPreferencesMap)
instance_id="main_navigation_menu"
/>