Theme policies
- Theme policy attributes
- Provided theme policies
- Set theme policy on a page using the XML configuration interface
- Use theme policy in a JSP
- Update a theme policy
- Export a theme policy
- Delete a theme policy
- Create your own theme policy
- Related information
Overview
Theme policy is used to control how a theme is rendered on a page. A policy is created and stored using the XML configuration interface.Once stored, it can be applied to a page either through the XML configuration interface using the page metadata attribute com.ibm.portal.ThemePolicy or the Properties portlet. Theme policy is inherited so it only needs to be set on a page which requires a different policy than its parent.
Theme policy attributes
A theme policy is made up of several attributes, where each attribute controls one aspect of the theme. The following table provides type and functional information on all available theme policy attributes. For a full listing, export the theme policy.
Attribute Type Function renderMainMenu Boolean If true, the main menu is rendered renderTopNavigation Boolean If true, top navigation is rendered renderMainMenuActions Boolean If true, the main menu actions are rendered renderSelfCare Boolean If true, Selfcare is rendered renderBreadCrumbTrail Boolean If true, the bread crumb trail is rendered render renderSearch Boolean If true, search is rendered renderToolBar Boolean If true, the tool bar is rendered renderContentPalette Boolean If true, the portlet palette is rendered renderPeoplePalette Boolean If true, the people palette is rendered renderContextMenus Boolean If true, context menus are render renderSideNavigation Boolean If true, side navigation is rendered renderTaskBar Boolean If true, the task bar is rendered renderFavorites Boolean If true, favorites is rendered renderExtensions Boolean If true, extensions are rendered renderBannerTitleGraphic Boolean If true, the banner title graphic is rendered as long as one exists renderPortletFragmentIDAnchor Boolean Determine if the user is on a palette page renderBannerTitle Boolean If true, the banner title is rendered as long as one exists breadCrumbMaxLevels Integer Number of steps listed in the bread crumb trail breadCrumbStartLevel Integer Which level to start the bread crumb trail rootNavigationStartLevel Integer Start level for root navigation rootNavigationStopLevel Integer Stop level for root navigation topNavigationNumRows Integer Number of rows to render for top navigation topNavigationStartLevel Integer Start level for top navigation topNavigationStopLevel Integer Stop level for top navigation sideNavigationStartLevel Integer Start level for side navigation
Provided theme policies
WebSphere Portal provides ten policies that may be used without alteration. The following information provide lists of each policy along with the corresponding attributes, values, and types.
SingleTopNav
renderMainMenu = TRUE
renderTopNavigation = TRUE
renderMainMenuActions= TRUE
renderSelfCare = TRUE
renderBreadCrumbTrail = TRUE
renderSearch = TRUE
renderToolBar = TRUE
renderContentPalette = TRUE
renderPeoplePalette = TRUE
renderContextMenus = TRUE
renderSideNavigation = TRUE
renderTaskBar = TRUE
renderFavorites = TRUE
renderExtensions = TRUE
renderBannerTitleGraphic = TRUE
renderBannerTitle=TRUE
renderPortletFragmentIDAnchor=TRUE
breadCrumbMaxLevels = 5
breadCrumbStartLevel = 1
rootNavigationStartLevel = 1
rootNavigationStopLevel = 1
topNavigationNumRows = 1
topNavigationStartLevel = 2
topNavigationStopLevel = 2
sideNavigationStartLevel = 3
SingleTopNavMinimal
renderMainMenu = TRUE
renderTopNavigation = TRUE
renderMainMenuActions = FALSE
renderSelfCare = FALSE
renderBreadCrumbTrail = FALSE
renderSearch = FALSE
renderToolBar = FALSE
renderContentPalette = FALSE
renderPeoplePalette = FALSE
renderContextMenus = FALSE
renderSideNavigation = TRUE
renderTaskBar = FALSE
renderFavorites = FALSE
renderExtensions = FALSE
renderBannerTitleGraphic = FALSE
renderBannerTitle = FALSE
renderPortletFragmentIDAnchor=TRUE
breadCrumbMaxLevels = 0
breadCrumbStartLevel = 0
rootNavigationStartLevel = 1
rootNavigationStopLevel = 1
topNavigationNumRows = 1
topNavigationStartLevel = 2
topNavigationStopLevel = 2
sideNavigationStartLevel = 3
DoubleTopNav
renderMainMenu = TRUE
renderTopNavigation = TRUE
renderMainMenuActions = TRUE
renderSelfCare = TRUE
renderBreadCrumbTrail = TRUE
renderSearch = TRUE
renderToolBar = TRUE
renderContentPalette = TRUE
renderPeoplePalette = TRUE
renderContextMenus = TRUE
renderSideNavigation = TRUE
renderTaskBar = TRUE
renderFavorites = TRUE
renderExtensions = TRUE
renderBannerTitleGraphic = TRUE
renderBannerTitle = TRUE
renderPortletFragmentIDAnchor=TRUE
breadCrumbMaxLevels = 5
breadCrumbStartLevel = 1
rootNavigationStartLevel = 1
rootNavigationStopLevel = 1
topNavigationNumRows = 2
topNavigationStartLevel = 2
topNavigationStopLevel = 3
sideNavigationStartLevel = 4
DoubleTopNavMinimal
renderMainMenu = TRUE
renderTopNavigation= TRUE
renderMainMenuActions = FALSE
renderSelfCare = FALSE
renderBreadCrumbTrail = FALSE
renderSearch = FALSE
renderToolBar = FALSE
renderContentPalette = FALSE
renderPeoplePalette = FALSE
renderContextMenus = FALSE
renderSideNavigation = TRUE
renderTaskBar = FALSE
renderFavorites = FALSE
renderExtensions = FALSE
renderBannerTitleGraphic = FALSE
renderBannerTitle = FALSE
renderPortletFragmentIDAnchor=TRUE
breadCrumbMaxLevels = 0
breadCrumbStartLevel = 0
rootNavigationStartLevel = 1
rootNavigationStopLevel = 1
topNavigationNumRows = 2
topNavigationStartLevel = 2
topNavigationStopLevel = 3
sideNavigationStartLevel = 4
SideNavOnly
renderMainMenu = TRUE
renderTopNavigation = FALSE
renderMainMenuActions = TRUE
renderSelfCare = TRUE
renderBreadCrumbTrail = TRUE
renderSearch = TRUE
renderToolBar = TRUE
renderContentPalette = TRUE
renderPeoplePalette = TRUE
renderContextMenus = TRUE
renderSideNavigation = TRUE
renderTaskBar = TRUE
renderFavorites = TRUE
renderExtensions = TRUE
renderBannerTitleGraphic = TRUE
renderBannerTitle = TRUE
renderPortletFragmentIDAnchor=TRUE
breadCrumbMaxLevels = 5
breadCrumbStartLevel = 1
rootNavigationStartLevel = 1
rootNavigationStopLevel = 1
topNavigationNumRows = 0
topNavigationStartLevel = 0
topNavigationStopLevel = 0
sideNavigationStartLevel = 2
SideNavOnlyMinimal
renderMainMenu = TRUE
renderTopNavigation = FALSE
renderMainMenuActions = FALSE
renderSelfCare = FALSE
renderBreadCrumbTrail = FALSE
renderSearch = FALSE
renderToolBar = FALSE
renderContentPalette = FALSE
renderPeoplePalette = FALSE
renderContextMenus = FALSE
renderSideNavigation =TRUE
renderTaskBar = FALSE
renderFavorites = FALSE
renderExtensions = FALSE
renderBannerTitleGraphic = FALSE
renderBannerTitle = FALSE
renderPortletFragmentIDAnchor=TRUE
breadCrumbMaxLevels = 5
breadCrumbStartLevel = 0
rootNavigationStartLevel = 1
rootNavigationStopLevel = 1
topNavigationNumRows = 0
topNavigationStartLevel = 0
topNavigationStopLevel = 0
sideNavigationStartLevel = 2
NoTheme
renderMainMenu = FALSE
renderTopNavigation = FALSE
renderMainMenuActions = FALSE
renderSelfCare = FALSE
renderBreadCrumbTrail = FALSE
renderSearch = FALSE
renderToolBar = FALSE
renderContentPalette = FALSE
renderPeoplePalette = FALSE
renderContextMenus = FALSE
renderSideNavigation = FALSE
renderTaskBar = FALSE
renderFavorites = FALSE
renderExtensions = FALSE
renderBannerTitleGraphic = FALSE
renderBannerTitle = FALSE
renderPortletFragmentIDAnchor=FALSE
breadCrumbMaxLevels = 0
breadCrumbStartLevel = 0
rootNavigationStartLevel = 0
rootNavigationStopLevel = 0
topNavigationNumRows = 0
topNavigationStartLevel = 0
topNavigationStopLevel = 0
sideNavigationStartLevel = 0
Federation
The Federation theme policy cannot be applied to a page either through the XML configuration interface using the page attribute com.ibm.portal.ThemePolicy or the Properties portlet.
- renderMainMenu = FALSE
- renderTopNavigation = FALSE
- renderMainMenuActions = FALSE
- renderSelfCare = FALSE
- renderBreadCrumbTrail = FALSE
- renderSearch = TRUE
- renderToolBar = TRUE
- renderContentPalette = TRUE
- renderPeoplePalette = TRUE
- renderContextMenus = FALSE
- renderSideNavigation = FALSE
- renderTaskBar = FALSE
- renderFavorites = FALSE
- renderExtensions = FALSE
- renderBannerTitleGraphic = FALSE
- renderBannerTitle = FALSE
- renderPortletFragmentIDAnchor=TRUE
- breadCrumbMaxLevels = 0
- breadCrumbStartLevel = 0
- rootNavigationStartLevel = 0
- rootNavigationStopLevel = 0
- topNavigationNumRows = 0
- topNavigationStartLevel = 0
- topNavigationStopLevel = 0
- sideNavigationStartLevel = 0
SingleTopNavLevel2
- renderMainMenu = TRUE
- renderTopNavigation = TRUE
- renderMainMenuActions= TRUE
- renderSelfCare = TRUE
- renderBreadCrumbTrail = TRUE
- renderSearch = TRUE
- renderToolBar = TRUE
- renderContentPalette = TRUE
- renderPeoplePalette = TRUE
- renderContextMenus = TRUE
- renderSideNavigation = TRUE
- renderTaskBar = TRUE
- renderFavorites = TRUE
- renderExtensions = TRUE
- renderBannerTitleGraphic = TRUE
- renderBannerTitle = TRUE
- renderPortletFragmentIDAnchor=TRUE
- breadCrumbMaxLevels = 5
- breadCrumbStartLevel = 2
- rootNavigationStartLevel = 1
- rootNavigationStopLevel = 1
- topNavigationNumRows = 1
- topNavigationStartLevel = 2
- topNavigationStopLevel = 2
- sideNavigationStartLevel = 3
Palette
- renderMainMenu = TRUE
- renderTopNavigation = TRUE
- renderMainMenuActions= TRUE
- renderSelfCare = TRUE
- renderBreadCrumbTrail = TRUE
- renderSearch = TRUE
- renderToolBar = TRUE
- renderContentPalette = TRUE
- renderPeoplePalette = TRUE
- renderContextMenus = TRUE
- renderSideNavigation = TRUE
- renderTaskBar = TRUE
- renderFavorites = TRUE
- renderExtensions = TRUE
- renderBannerTitleGraphic=TRUE
- renderBannerTitle=TRUE
- renderPortletFragmentIDAnchor=FALSE
- breadCrumbMaxLevels = 5
- breadCrumbStartLevel = 1
- rootNavigationStartLevel = 1
- rootNavigationStopLevel = 1
- topNavigationNumRows = 1
- topNavigationStartLevel = 2
- topNavigationStopLevel = 2
- sideNavigationStartLevel = 3
The Federation, SingleTopNavLevel2, and Palette theme policies should not be modified.
Custom theme attributes
In addition to the attributes in each policy above, we can add an attribute to the theme policies and then use it in the JSP or JSPF. The following code samples show how the custom attribute renderTestAttribute is added to theme policy and how it is accessed in a JSP or JSPF. The main theme policy must have the attribute and a lock attribute. This is added to the root theme policy as follows:
<policyValue Name="renderTestAttribute" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderTestAttributeLock" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>false</value> </policyValue>To add the attribute to each theme policy that requires a value different from the root theme policy:
<policyValue Name="renderTestAttribute" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>false</value> </policyValue>Since this is a Boolean, the value would be set to true or false. To access the attribute in a JSP or JSPF:
<% boolean isTestAttribute = themePolicy.getValueAsBoolean("renderTestAttribute", false); if(isTestAttribute){%> <p> Display this paragrah if renderTestAttribute is true. </p> <%}%>In the above example, if the value of renderTestAttribute is true, the paragraph is displayed. themePolicy is defined in Using theme policy in a JSP. There are three accessor methods:
getValueAsBoolean(String key, boolean defaultValue);
getValueAsInt(String key, int defaultValue);
getValueAsString(String key, String defaultValue);
where key is the name of the attribute and defaultValue is the value that will be used if the attribute value can not be retrieved from the theme policy.
Set theme policy on a page using the XML configuration interface
Theme Policy can be applied to a page through the XML configuration interface using the page metadata attribute com.ibm.portal.ThemePolicy. The following provides an example of an XML script that sets the page metadata for the theme policy for the page ThemePolicyPageTest:
<request type="update" create-oids="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd"> <portal action="locate"> <content-node action="update" ordinal="last" uniquename="ibm.portal.ThemePolicyPageTest" content-parentref="Content.Root" active="true" allportletsallowed="false" create-type="explicit" objectid="wp.theme.policytestpage" type="page"> <supported-markup markup="html" update="set"/> <!--@LocaleData_1@--> <parameter name="com.ibm.portal.ThemePolicy" type="string" update="set">theme/SingleTopNavMinimal</parameter> </content-node> </portal> </request>
Use theme policy in a JSP
To use a theme policy directly in a JSP...
<themepolicy:initthemepolicy/> <jsp:useBean id="themePolicy" class="com.ibm.portal.theme.policy.ThemePolicyBean" scope="page"/> <% themePolicy.setValuesMap(portalThemePolicyMap);%>In this code example, the theme bean is initialized which wrappers the theme policy attributes.
To use an attribute in the JSP, reference it with the following syntax: ${themePolicy.attribute) where the attribute would be, for example, renderSideNavigation. The following code tests renderSideNavigation. If it is TRUE, the following code is executed:
<c-rt:if test = "${themePolicy.renderSideNavigation}"> <!-- following code --> <….> <….> </c-rt:if>The following code example sets startLevel to the value of the theme policy attribute sideNavigationStartLevel:
<portal:navigation startLevel="${themePolicy.sideNavigationStartLevel}"
Update a theme policy
To update a theme policy...
- Export the theme policy.
- Edit the values of the attributes to be updated.
- Use the XML configuration interface to run addThemePolicyNode.xml which references the file that has the updated theme policy definition.
Extend and update a theme policy
To extend a theme policy by adding attributes...
- Export the entire theme policy structure
- Add the attribute to the root theme policy.
- Add the attribute to the theme policy.
- Run addThemePolicyNode.xml.
To modify the value of an attribute that already exists in a theme policy...
- Export the theme policy
- Make changes to the attribute.
- Run addThemePolicyNode.xml.
Export a theme policy
Export all theme policies. Save the following to exportTheme.xml...
<?xml version="1.0" encoding="UTF-8"?> <request xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd" create-oids="true" type="export" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <portal action="locate"> <policy-node action="export" label="WebPage" type="theme" path=""> <url>file:///c:/temp/exportThemePolicies.xml</url> </policy-node> </portal> </request>...and then execute something like...
xmlaccess.sh-user wpsadmin-password password-in exportTheme.xml-out oTheme.xml -url http://localhost:10038/wps/configExport the TestThemePolicy theme policy:
<?xml version="1.0" encoding="UTF-8"?> <request xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd" create-oids="true" type="export" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <portal action="locate"> <policy-node action="export" label="WebPage" type="theme" path="TestThemePolicy"> <url>file:///c:/temp/exportTestThemePolicy.xml</url> </policy-node> </portal>
Delete a theme policy
To delete a theme policy, run deleteThemePolicyNode.xml.
<!-- deleteThemePolicyNode.xml --> <request xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd" create-oids="true" type="update" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <portal action="locate"> <policy-node action="delete" label="WebPage" type="theme" path="TestThemePolicy"> </policy-node> </portal> </request>For the "path" attribute, "PznType" is the identifier of the policy used in the XML file. Specifically, "PznType" is the actual Java Content Repository (JCR) XPath name of the child node.
XPath is a search language designed for selecting elements from an XML document (such as a theme policy). A policy is located in a search by an XPath using something the following...
Root/Child1/Child2.
Create your own theme policy
The following code example addThemePolicyNode.xml provides an example of how to create and add a new theme policy. This XML file would then be updated to reflect the location and name of the file which contains the theme policy XML definition.
<?xml version="1.0" encoding="UTF-8"?> <request xsi:noNamespaceSchemaLocation="PortalConfig_1.4.xsd" create-oids="true" type="update" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <portal action="locate"> <policy-node action="update" label="WebPage" type="" path=""> <url>file:///c:/temp/addTestThemePolicyNode.xml</url> </policy-node> </portal> </request>Use the XML configuration interface to run addThemePolicyNode.xml which references the TestThemePolicy definition file addTestThemePolicyNode.xml listed as follows. This file represents the theme policy XML definition.
It is important that the following attributes in this file be set as follows:
- Type attribute should be set to "theme"
- PathType attribute should be set to "/theme"
- PznType and Title attributes should have the same value.
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed Materials - Property of IBM, 5724-E76, 5655-R17, (C) Copyright IBM Corp. 2006 - All Rights reserved. --> <policyList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Policy.xsd"> <policy> <policyValue Name="Path" Factory="com.ibm.wps.policy.parse.StringFactory"> <value></value> </policyValue> <policyValue Name="Type" Factory="com.ibm.wps.policy.parse.StringFactory"> <value>theme</value> </policyValue> <policyValue Name="Description" Factory="com.ibm.wps.policy.parse.StringFactory"> <value>Test Theme Policy</value> </policyValue> <policyValue Name="Title" Factory="com.ibm.wps.policy.parse.StringFactory"> <value>TestThemePolicy</value> </policyValue> <policyValue Name="Editor" Factory="com.ibm.wps.policy.parse.StringFactory"> <value></value> </policyValue> <policyValue Name="NameResKey" Factory="com.ibm.wps.policy.parse.StringFactory"> <value></value> </policyValue> <policyValue Name="PznRule" Factory="com.ibm.wps.policy.parse.StringFactory"> <value></value> </policyValue> <policyValue Name="PznType" Factory="com.ibm.wps.policy.parse.StringFactory"> <value>TestThemePolicy</value> </policyValue> <policyValue Name="Remote" Factory="com.ibm.wps.policy.parse.StringFactory"> <value></value> </policyValue> <policyValue Name="PathType" Factory="com.ibm.wps.policy.parse.StringFactory"> <value>/theme</value> </policyValue> <policyValue Name="renderMainMenu" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderTopNavigation" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderMainMenuActions" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderSelfCare" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderBreadCrumbTrail" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderSearch" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderToolBar" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderContentPalette" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderPeoplePalette" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderContextMenus" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderSideNavigation" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderTaskBar" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderFavorites" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderExtensions" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderBannerTitleGraphic" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderBannerTitle" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="renderPortletFragmentIDAnchor" Factory="com.ibm.wps.policy.parse.BooleanFactory"> <value>true</value> </policyValue> <policyValue Name="breadCrumbMaxLevels" Factory="com.ibm.wps.policy.parse.IntegerFactory"> <value>5</value> </policyValue> <policyValue Name="breadCrumbStartLevel" Factory="com.ibm.wps.policy.parse.IntegerFactory"> <value>1</value> </policyValue> <policyValue Name="rootNavigationStartLevel" Factory="com.ibm.wps.policy.parse.IntegerFactory"> <value>1</value> </policyValue> <policyValue Name="rootNavigationStopLevel" Factory="com.ibm.wps.policy.parse.IntegerFactory"> <value>1</value> </policyValue> <policyValue Name="topNavigationNumRows" Factory="com.ibm.wps.policy.parse.IntegerFactory"> <value>1</value> </policyValue> <policyValue Name="topNavigationStartLevel" Factory="com.ibm.wps.policy.parse.IntegerFactory"> <value>2</value> </policyValue> <policyValue Name="topNavigationStopLevel" Factory="com.ibm.wps.policy.parse.IntegerFactory"> <value>2</value> </policyValue> <policyValue Name="sideNavigationStartLevel" Factory="com.ibm.wps.policy.parse.IntegerFactory"> <value>3</value> </policyValue> <policyValue Name="Version" Factory="com.ibm.wps.policy.parse.StringFactory"> <value>1.0</value> </policyValue> </policy> </policyList>
Related information
- Customize the portal
- Work with portal navigation
- Tags used by the portal JSPs
- Layout of the portal page
- Themes
- Screens
- Skins
- Aggregation
- Manage portal resources with policies