Theme policies

  1. Overview
  2. Theme policy attributes
  3. Provided theme policies
  4. Set theme policy on a page using xmlaccess.sh
  5. Use theme policy in a JSP
  6. Create own theme policy
  7. Update a theme policy
  8. Export a theme policy
  9. Delete a theme policy


Overview

Theme policy controls how a theme is rendered on a page.

Policies are created using xmlaccess.sh. Once stored, they are applied to a page either through...

Theme policy is inherited so it only needs to be set on a page which requires a different policy than its parent.

Page builder and the Page Builder theme do not support theme policies.


Theme policy attributes

A theme policy is made up of several attributes. Each attribute controls one aspect of the theme. For example, the boolean attribute...

.controls whether the bread crumb will be displayed. The attribute...

.controls the number of steps listed in the bread crumb when it is displayed.


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
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 Used to 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 Indicates 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
isCustomizable Boolean If true, the policy can be edited in the Theme Customizer portlet.
isDeletable Boolean If true, the policy can be deleted in the Theme Customizer portlet. xmlaccess ignores this attribute.
colorPalette String If specified, the value in this attribute is the name of the color palette.

The search order for the name of the color palette used on the page is:

  1. colorPalette page meta data attribute
  2. colorPalette attribute in the policy assigned to the current page
  3. string "default"

The name of the color palette must be the name of a properties file provided in the theme without the .properties extension.
colorPaletteProperties String Color Palette information. This is a stored java.util.Properties object created by the Theme Customizer portlet. The theme first loads the color palette for the page and then overwrites those values with any that may be present in this attribute.
graphicFilesMimeData String If specified, graphic files uploaded through the Theme Customizer portlet. This attribute is a standard multipart/mixed MIME text stream containing attachments encoded with Base64 encoding.
styleVersion Integer The version number of the policy. This value is incremented each time the Theme Customizer portlet saves the policy so updates to the policy can be loaded without clearing the browser cache.
bannerTitleText String Text that is to be displayed as the title in the banner and browser title bar.

If empty, the bannerTitleTextResourceBundle and bannerTitleTextResourceKey attributes are used to determine the title text.

bannerTitleTextResourceBundle String Resource bundle containing the title text.
bannerTitleTextResourceKey String Resource bundle key that is to be used to locate the title
bannerTitleGraphic String URI of the title graphic to be displayed in the banner. This value is passed on the uri attribute of the portal-resolver:url tag.

Values created by the Theme Customizer portlet are of the form:

    themeGraphic:policy:filePath:xxx

.where xxx is the name of the attachment stored in the attribute...

    graphicFilesMimeData
renderBannerQuickLinks Boolean If true, banner quick links are rendered
renderHelpLink Boolean If true, the help link is rendered
renderQuickLinksShelf Boolean If true, the quick links shelf is rendered
quickLinksShelfStyle Integer Style attributes for the quick links shelf. This is a bitmask field. If bit 1 is turned on, the quick links shelf default state is expanded. If bit 2 is turned on, the expand/collapse link is hidden.

As such, the following values are supported:

    0 = shelf state is collapsed and the expand/collapse link is shown
    1 = shelf state is expanded and the expand/collapse link is shown
    2 = shelf state is collapsed and the expand/collapse link is hidden
    3 = shelf state is expanded and the expand/collapse link is hidden

Numbers other than 0, 1, 2, or 3 are reserved for future use.

renderApplicationName Boolean If true, the application name is rendered
renderCustomizeThemeLink Boolean If true, the theme customizer link is rendered


Provided theme policies

WebSphere Portal provides ten policies that may be used without alteration. The following information provides lists of each policy along with the corresponding attributes, values, and types.

The Federation, SingleTopNavLevel2, and Palette theme policies should not be modified.


Default


SingleTopNav


SingleTopNavMinimal


DoubleTopNav


DoubleTopNavMinimal


SideNavOnly


SideNavOnlyMinimal


NoTheme


Federation

The Federation theme policy cannot be applied to a page either through xmlaccess.sh using the page attribute com.ibm.portal.ThemePolicy or the Properties portlet.


SingleTopNavLevel2


Palette


Custom theme attributes

In addition to the attributes in each policy above, you can add an attribute to the theme policies and then use it in 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>

The policy value sets consisting of attributes and their values can be nested. Child attributes can either inherit or override the values from the parent attribute. When you specify the value of a lock attribute corresponding to a policy attribute as true, you lock the policy node. In this case, the child attributes necessarily inherit the values from parent attributes and cannot override these values.

Use the following code 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.

Use the following code to access the attribute in a JSP or JSPF:

<% boolean isTestAttribute = themePolicy.getValueAsBoolean("renderTestAttribute", false); 
if(isTestAttribute){%>      
<p> Display this paragraph if renderTestAttribute is true. </p>
<%}%>

In the above example, if the value of renderTestAttribute is true, the paragraph is displayed. themePolicy is defined in the Using theme policy in a JSP section of this topic.

There are three accessor methods:

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 xmlaccess.sh

Theme Policy can be applied to a page through xmlaccess.sh 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

You can also use a theme policy directly in a JSP. Use the following code to do this:

<themepolicy:initthemepolicy/>

<jsp:useBean id="themePolicy"
             class="com.ibm.portal.theme.policy.ThemePolicyBean" 
             scope="page"/>

<% themePolicy.setValuesMap(portalThemePolicyMap);%>

In this code sample, the theme bean is initialized which wrappers the theme policy attributes.

To use an attribute in the JSP, reference it with the following syntax:

.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 sample sets startLevel to the value of the theme policy attribute sideNavigationStartLevel:

<portal:navigation  startLevel="${themePolicy.sideNavigationStartLevel}"


Create own theme policy

Use xmlaccess.sh to add the TestThemePolicy definition. The code sample shown in the following represents the theme policy XML definition.

Set the following attributes in this file as follows:

<?xml version="1.0" encoding="UTF-8"?>

<request build="wp700_586_01" 
            type="update" 
            version="7.0.0.0" 
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
            xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd">

    <portal action="locate">

        <policy-node action="update" 
                     path="/theme/TestThemePolicy">

            <parameter name="Description" 
                       type="string" 
                       update="set"><! [CDATA [Test Theme Policy]]&gt;</parameter>
            <parameter name="Path" 
                       type="string" 
                       update="set"><! [CDATA [./TestThemePolicy]]&gt;</parameter>
            <parameter name="PathType" 
                       type="string" 
                       update="set"><! [CDATA [/theme]]&gt;</parameter>
            <parameter name="PznRule" 
                       type="string" 
                       update="set"/>
            <parameter name="PznType" 
                       type="string" 
                       update="set"><! [CDATA [TestThemePolicy]]&gt;</parameter>
            <parameter name="Remote" 
                       type="string" 
                       update="set"/>
            <parameter name="Title" 
                       type="string" 
                       update="set"><! [CDATA [TestThemePolicy]]&gt;</parameter>
            <parameter name="Type" 
                       type="string" 
                       update="set"><! [CDATA [theme]]&gt;</parameter>
            <parameter name="breadCrumbMaxLevels" 
                       type="integer" 
                       update="set">5</parameter>
            <parameter name="breadCrumbStartLevel" 
                       type="integer" 
                       update="set">1</parameter>
            <parameter name="renderBannerTitle" 
                       type="boolean" 
                       update="set">true</parameter>
            <parameter name="renderBannerTitleGraphic" 
                       type="boolean" 
                       update="set">true</parameter>
            <parameter name="renderBreadCrumbTrail" 
                       type="boolean" 
                       update="set">false</parameter>
            <parameter name="renderContentPalette" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderContextMenus" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderExtensions" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderFavorites" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderMainMenu" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderMainMenuActions" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderPeoplePalette" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderPortletFragmentIDAnchor" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderSearch" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderSelfCare" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderSideNavigation" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderTaskBar" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderToolBar" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="renderTopNavigation" 
                   type="boolean" 
                   update="set">true</parameter>
            <parameter name="rootNavigationStartLevel" 
                   type="integer" 
                   update="set">1</parameter>
            <parameter name="rootNavigationStopLevel" 
                   type="integer" 
                   update="set">1</parameter>
            <parameter name="sideNavigationStartLevel" 
                   type="integer" 
                   update="set">4</parameter>
            <parameter name="topNavigationNumRows" 
                   type="integer" 
                   update="set">2</parameter>
            <parameter name="topNavigationStartLevel" 
                   type="integer" 
                   update="set">2</parameter>
            <parameter name="topNavigationStopLevel" 
                   type="integer" 
                   update="set">3</parameter>
        </policy-node>
    </portal>
</request>


Update a theme policy

To only update a theme policy, use the following guidelines:


Extend and update a theme policy

If during an update you also want to extend a theme policy by adding attributes to it, you need to add the attribute(s) also to the root theme policy. Use the following guidelines to do this:

If you only want to modify the value of an attribute that already exists in a theme policy, use the following guidelines:


Export a theme policy

Adapt the following code sample to export a theme policy. This example exports all theme policies.

<?xml version="1.0" encoding="UTF-8"?>

<request xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd"  
         create-oids="true" 
         type="export"   
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <portal action="locate">
        <policy-node action="export" 
                     path="/theme" />
    </portal>
</request> 

Here is alternate export all theme policies.

<?xml version="1.0" encoding="UTF-8"?>

<request xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd"  
         create-oids="true" 
         type="export"   
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <portal action="locate">
        <policy-node action="export" 
                     path="/theme" />
    </portal>
</request> 

The following code sample exports only the theme policy named TestThemePolicy :

<?xml version="1.0" encoding="UTF-8"?>
<request xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd" 
         create-oids="true" 
         type="export" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <portal action="locate">
        <policy-node action="export" path="/theme/TestThemePolicy" />
    </portal>
</request>

Here is alternate export theme policy named TestThemePolicy:

<?xml version="1.0" encoding="UTF-8"?>
<request xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd" 
         create-oids="true" 
         type="export" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <portal action="locate">
        <policy-node action="export" path="/theme/TestThemePolicy" />
    </portal>
</request>

Ref: html-wrapper-wcm-accessible.html#dgn_thempolicy


Delete a theme policy

Adapt the following code sample to delete a theme policy:

<request xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd"
         create-oids="true" 
         type="update" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <portal action="locate">
        <policy-node action="delete" path="/theme/TestThemePolicy">
        </policy-node>
    </portal>
</request>


Parent

Layout of the portal page


+

Search Tips   |   Advanced Search