« Back to FrontPage

Display Theme's Images in Portlets

If for some reason we need to use Liferay 5.2 theme's images in our portlet, there is a very easy way of doing this. 

First in our jsp we need to import the Liferay Theme Taglib this way:

<%@taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>

This allow us to use the

<liferay-theme: ... >

tag to access some important functions. The one we need to use here is

<liferay-theme:defineObjects />

After this call a lots of objects are availables in our jsp. The one we are interested for is

themeDisplay

We are going to use it to get the theme's images path so we can use it into an img tag this way

<img src="${themeDisplay.getPathThemeImages}/folder/image.png" />

For example suppose that into your jsp you want to display the italian flag icon. To do this you just have to write this code

...other jsp imports...

<%@taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>

<liferay-theme:defineObjects />

...other jsp code...

<!-- Here we display the italian flag image -->
<img src="${themeDisplay.getPathThemeImages}/language/it_IT.png" />
0 Attachments
1041 Views
Average (0 Votes)
Comments

Showing 0 Comments