Intro
In order to maintain a consistent look and feel custom portlets should use images and styles from the standard theme as much as possible.
Applies to
Liferay 4+ portlets built with xml compliant JSPs.
First we need to reference the liferay theme tag library:
xmlns:liferay-theme="http://liferay.com/tld/theme"
Next in the JSP we need to instantiate the liferay objects:
<liferay-theme:defineObjects />
Now the following objects are available:
- themeDisplay - com.liferay.portal.theme.ThemeDisplay
- company - com.liferay.portal.model.Company
- account - com.liferay.portal.model.Account (deprecated)
- user - com.liferay.portal.model.User
- realUser - com.liferay.portal.model.User
- contact - com.liferay.portal.model.Contact
- ?layout - com.liferay.portal.model.Layout
- ?layouts - List<com.liferay.portal.model.Layout>
- plid - java.lang.Long
- ?layoutTypePortlet - com.liferay.portal.model.LayoutTypePortlet
- portletGroupId - java.lang.Long
- permissionChecker - com.liferay.portal.security.permission.PermissionChecker
- locale - java.util.Locale
- timeZone - java.util.TimeZone
- theme - com.liferay.portal.model.Theme
- colorScheme - com.liferay.portal.model.ColorScheme
- portletDisplay - com.liferay.portal.theme.PortletDisplay
Displaying theme images
Now we can succesfully reference theme images!!
<img src="${themeDisplay.pathThemeImages}/mail/compose.png"/>