Documentation
Liferay provides a rich store of resources and knowledge to help our community better use and work with our technology.
Settings
Each theme can define settings to make it configurable. These settings are defined in a file named liferay-look-and-feel.xml inside WEB-INF. This file does not exist by default, so you should now create it with the following content:
<?xml version="1.0"?>
<!DOCTYPE look-and-feel PUBLIC "-//Liferay//DTD Look and Feel 6.0.0//EN" "http://www.liferay.com/dtd/liferay-look-and-feel_6_0_0.dtd">
<look-and-feel>
<compatibility>
<version>6.0.0+</version>
</compatibility>
<theme id="deep-blue" name="Deep Blue">
<settings>
<setting key="my-setting" value="my-value" />
</settings>
</theme>
</look-and-feel>
You can define additional settings by adding more <setting> elements. These settings can be accessed in the theme templates using the following code:
$theme.getSetting("my-setting")
For example, say we need to create two themes that are exactly the same except for some changes in the header. One of the themes has more details while the other is smaller (and takes less screen real estate). Instead of creating two different themes, we are going to create only one and use a setting to choose which header we want.
In the portal_normal.vm template we could write:
#if ($theme.getSetting("header-type") == "detailed")
#parse ("$full_templates_path/header_detailed.vm")
#else
#parse ("$full_templates_path/header_brief.vm")
#end
Then when we write the liferay-look-and-feel.xml, we write two different entries that refer to the same theme but have a different value for the header-type setting:
<theme id="deep-blue" name="Deep Blue">
<settings>
<setting key="header-type" value="detailed" />
</settings>
</theme>
<theme id="deep-blue-mini" name="Deep Blue Mini">
<settings>
<setting key="header-type" value="brief" />
</settings>
</theme>