Liferay: Create Web Content using Structures and Templates
The other day I was trying to figure out a good way to manage footer navigation in liferay through manage pages.
I wanted the theme to create a custom field of boolean type that could be set on a page. The benifit of the theme creating the custom field is that then the theme will know the name of the field to look for inorder to filter the navigation.
Here is what the navigation looks like. Footer Group 1 and Footer Group 2 have the Custom Field of “Footer Navigation” set to true.

Here is what the theme looks like.

Here is the code:
I create a variable called customFieldName so I can use that through my other vm files. I use the ExpandoBridge from the $layout class so the custom field will be added to the Page type in the custom fields. It checks to see if the custom field exsists, if not then it creates it.
Here are some velocity variables you can use to check permission in the theme such as “portal_normal.vm”
$theme_display.getPermissionChecker().isOmniadmin()
- Returns true if the user is a universal administrator.
$theme_display.getPermissionChecker().isCompanyAdmin()
- Returns true if the user is an administrator of their company.
$theme_display.getPermissionChecker().isCompanyAdmin($theme_display.companyId)
- Returns true if the user is an administrator of the company.
$nav_item.getLayout().getExpandoBridge().getAttribute(“custom_field_attribute_name”)
This code logs you out and then reloads the current community instead of sending you to the guest community.
I came across some velocity variables (1.6.4) that could help you save a couple lines of code.
$velocityCount: Current index of the foreach loop (starts at 1)
$velocityHasNext: Checks if there is another item in the loop
-Freemarker version
(Source: velocity.apache.org)
If the article ids differ from dev and the prod server this method will grab the articleid from the article title
Add “journal.template.velocity.restricted.variables=” to your portal-ext.properties file to extend
$numberTool.currency($price.data)