Create a new theme
Themes are a set of JSPs, images, and style sheets packaged as a WAR file. As deployable units, they have to follow a certain file layout which is jointly determined by the application server and the portal server.
If you have created themes or skins for an earlier release of WebSphere Portal you will be able to migrate most of that work because the file layout and the lookup mechanisms to locate resources have not changed. However, the lookup only works within the same deployable unit, so resources can only be shared between themes that reside in the same WAR file.
Defining your own theme involves creating the directory structure for the artifacts of the theme. Typically, these reside in a subdirectory using the theme name, although technically that is not necessary as long as this WAR file will only contain one and only one theme.
Themes are located under...
was_profile_root/installedApps/cell/wps.ear/wps.war/themesDeploying custom themes to wps.war involves creating theme resources and then war'ing them up. In MyTheme.war, for example, you would have the following directories
/themes
/themes/dojo
/themes/html
/themes/html/MyTheme
/WEB-INFYou can add your new MyTheme theme directory right under...
wps.war/themes/html
...and then go to...
Administration | Themes and Skins | Add New Theme...and it should work right away.
If a new wps.ear is deployed, your theme would get wiped out. Build and install the war file to add the theme permanently. Copies of the standard theme might require a fix to work. Check with IBM support.
If you install the MyTheme.war to the cluster it will be pushed to all nodes.
Package and deploy your custom theme
Themes can either be...
- Packaged directly in the wps.war
- Inside a separate WAR file of their own, or with other themes, skins, and resources.
The recommended best practice is to package them in a separate WAR file so that they are untouched across migrations and updates. This technique also enables them to be managed independently through staging operations without having to touch the wps.war application.
Deploying updates to themes in separate WAR files can be done without having to bring the Portal server offline.
The following steps describe one way of creating your own HTML-based theme using an existing theme...
- For themes included in wps.war, create...
themes/<markup>/mytheme
Do not use DBCS characters in the theme resource root directory name.
If packaging as part of wps.war:
Create a directory structure similar to existing themes directory structure. For example...
cd wp_profile/installedApps/F32BC/wps.ear/wps.war
cp -r themes /workarea/mythemesGenerally the themes directory will be a peer to the WAR's WEB-INF directory.
- Copy the ar, colors, icons, images, iw, js, and status messages subdirectories from the Portal theme directory into the new theme resource root directory. These are required if the new theme will be using many of the same theme resources that the Portal theme uses, including the necessary resources for the page and portlet context menus as well as resources required by administrative portlets.
Copy the resources under...
themes/html/psw
...into the WAR's directory...
themes/html/psw
Also copy all the images in the /themes/html directory into the WAR's /themes/html directory as they are required for many of the administrative portlets to work in the custom theme. If the new theme needs to use the same dojo package inside the wps.war, it is best to copy the entire dojo directory from the /themes directory in wps.war into the /themes directory of the new theme's WAR.
- Inside the theme resource root directory, create a file called Default.jsp which will be the main JSP file that the Portal server executes when rendering a Portal page using that theme. If desired, the Default.jsp and its dependent files can be copied from the Portal theme inside the wps.war as a starting point. The separate jspf files as well as the styles.jsp and its dependent .jspf files can be used in the custom theme but technically aren't required depending on the new theme's design.
Make updates to the following files according to the requirements of your portal site.
- JSPs
Default.jsp and its included JSPs are used to provide the appearance and layout and determine where the screen element goes. See the Themes topic for more detailed information about the JSPs (and JSPFs) that are used.
- Images Images are used for icons and tools within the theme pages. You can modify these images or create your own and add them to the JSPs.
- Style sheets
In order to handle the different locales and browsers supported by a theme, the style sheets are actually JSPs. The <portal-theme:cacheProxyUrl/> tag and servlet, which is used to make sure the output of CSS JSPs is cacheable, makes sure that the JSP is aware of the current browser and locale.
For security reasons, the cache proxy servlet will only serve URLs pointing to resources located in the themes, skins, and screens directories. This makes all resources underneath these directories public. Also, any URLs containing the ".." characters will not be served.
All style sheets reside in the css directory underneath the resource root directory of the respective theme. The main style sheet is styles.jsp, which contains only statically included JSP fragments (JSPFs - .jspf file extension). The easiest way to add your own styles is to create your own JSP fragment file and add it to styles.jsp You can change the style definitions. However, make sure that you do not delete any style sheets or remove any style classes.
If packaging in separate WAR, copy all of the tld files from the WEB-INF/tld directory in wps.war into the theme WAR's WEB-INF/tld directory in order to get support for all the custom tags used for themes and skins.
If you have problems with places where "portal-logic:urlFindInTheme" tag is used, try using this tld file, portal-v6-logic.zip, and restart your Theme war.
- To install the new theme in WebSphere Application Server, perform the steps described in the Deploying the theme section.
- To make the new theme available in WebSphere Portal:
- Import new theme by following the steps in the Importing a theme section. Note: You can only make the context root of a theme known through the XML configuration interface. There is a new context-root attribute on the theme element that is used for this purpose.
- Edit the properties of a test page and set the page to use the new theme that you created.
Be sure to use a test page for the new theme to work out any problems before setting the default page to the new theme. Setting the portal default to use a theme with errors can cause problems accessing the portal site.
- When you are ready to offer the theme for general use, create a preview that users and administrators can see from the page properties.
- Create a screen capture of the theme.
- Reduce the screen capture to fit in the preview box. Recommended size is 300 x 225 pixels.
- Name the image preview.gif. GIF files are limited to 256 colors.
- Copy the image to: themes/markup_type/theme_name. In this example, the file and location is: themes/html/MyTheme/preview.gif
If the Portal theme directory is either deleted or renamed, the portal resource loader uses the themes/html/Default.jsp. In this case, you should also use the fallback skin. To do this, rename the skins directory. For example, the skins/html/IBM directory should be renamed skins/html/IBM1. If you have a broken theme, you can rename the theme and skin directories which are causing the problem to get to a working minimal theme. Enabling Organize Favorites functionality in custom themes
The "My Favorites" feature in WebSphere Portal lets you bookmark a page in the portal so that you can return to it at a later time. The page is then added to your "My Favorites" list which is maintained by means of the Organize Favorites feature. Organize Favorites, a page containing the Organize Favorites portlet, lets you create, edit, activate, order, and delete labels and URLs in the My Favorites list.
In a default installation of WebSphere Portal Version 6.1, you cannot directly access Organize Favorites functionality. However, you can access this functionality in a newly created theme as follows:
- Use the <portal-navigation:navigation> tag with the scopeUniqueName attribute as wps.p.Favorites to create the links to the Favorites in the theme. This replaces the <portal:favoritesLoop/> tag for enabling Organize Favorites functionality.
- Create a URL to Organize Favorites in the theme using the <portal-navigation:urlGeneration> tag to wps.OrganizeFavorites.
- Create a My Favorite label as described in the topic, Enabling the Organize Favorites portlet in themes.
- Add <portal-logic:if/> tags with the pageBookmarkable attribute set to true to pages that you want to be able to bookmark.
Create your own HTML-based theme using an existing theme
- Create a new directory path...
themes/html/MyThemeTo avoid problems with the directory name, do not use DBCS characters.
- Copy all of the files and subdirectories from another theme directory into the new. For example...
WP_PROFILE/installedApps/CELL/wps.war/themes/html/Portal
If you use the Portal theme, also copy the resources under...
WP_PROFILE/installedApps/CELL/wps.war/themes/html/psw...which are required by this theme.
- Make updates to the following files according to the requirements of your portal site.
- JSPs
- Default.jsp and its included JSPs are used to provide the appearance and layout and determine where the screen element goes.
- Images
- Images are used for icons and tools within the theme pages. You can modify these images or create your own and add them to the JSPs.
- Style sheets
- In order to handle the different locales and browsers supported by a theme, the style sheets are actually JSPs. The tag and servlet...
<portal-theme:cacheProxyUrl/>...is used to make sure the output of CSS JSPs is cacheable and makes sure that the JSP is aware of the current browser and locale.
For security reasons, the cache proxy servlet will only serve URLs pointing to resources in themes, skins, and screens directories. This makes all resources underneath these directories public.
Any URLs containing the ".." characters will not be served.
Style sheets reside in the /css directory underneath the resource root directory of the respective theme. The main style sheet is styles.jsp, which contains only statically included JSP fragments (*.jspf).
To add your own styles, create your own JSP fragment file and add it to styles.jsp. Do not delete any style sheets or remove any style classes.
- Next to the "themes" directory, create a WEB-INF.
- In this directory, create a file named web.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="MyTheme" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>MyTheme</display-name> </web-app>- Copy the dojo directory from the wps.war file beneath the "themes" directory.
- Create the subdirectory WEB-INF/tld.
- Copy all tld files to the WEB-INF/tld.
- Wrap the new theme as MyTheme.war using a ZIP compression tool.
jar cvf MyTheme.war MyTheme
- To install the new theme in WAS:
- Open the application server admin console.
- Select...
Applications | Install New Application | Install...and proceed through the wizard to deploy the WAR file that you have just created.
Note the context root that the WAR file is deployed under because it will be required later.
- Verify the newly deployed web application is started.
- To make the new theme available in WebSphere Portal:
- Use the Themes and Skins portlet under...
Administration | Portal User InterfaceYou can only make the context root of a theme known through the XML configuration interface. There is a new context-root attribute on the theme element that is used for this purpose.
- Edit the properties of a test page and set the page to use the new theme that you created.
Be sure to use a test page for the new theme to work out any problems before setting the default page to the new theme. Setting the portal default to use a theme with errors can cause problems accessing the portal site.
- When you are ready to offer the theme for general use, create a preview that users and administrators can see from the page properties.
- Create a screen capture of the theme.
- Reduce the screen capture to fit in the preview box. Recommended size is 300 x 225 pixels.
- Name the image preview.gif. GIF files are limited to 256 colors.
- Copy the image to: themes/markup_type/theme_name. In this example, the file and location is:
themes/html/MyTheme/preview.gifIf the Portal theme directory is either deleted or renamed, the portal resource loader uses...
themes/html/Default.jspIn this case, you should also use the fallback skin. To do this, rename the skins.
For example, the directory...
skins/html/IBM...should be renamed...
skins/html/IBM1If you have a broken theme, you can rename the theme and skin directories which are causing the problem to get to a working minimal theme.
Enable Organize Favorites functionality in custom themes
The "My Favorites" feature in WebSphere Portal lets you bookmark a page in the portal so that you can return to it at a later time. The page is then added to your "My Favorites" list which is maintained by means of the Organize Favorites feature. Organize Favorites, a page containing the Organize Favorites portlet, lets you create, edit, activate, order, and delete labels and URLs in the My Favorites list.
In a default installation of WebSphere Portal v6, you cannot directly access Organize Favorites functionality. The following tasks, however, can be done to access Organize Favorites functionality in your newly created theme by doing the following:
- Use the tag...
<portal-navigation:navigation>...with the scopeUniqueName attribute as wps.p.Favorites to create the links to the Favorites in the theme. This replaces the tag...
<portal:favoritesLoop/>...for enabling Organize Favorites functionality.
- Create a URL to Organize Favorites in the theme using the tag...
<portal-navigation:urlGeneration>...to wps.OrganizeFavorites.
- Create a My Favorite label to store the favorites by doing the following:
- Click...
Administration | Portal User Interface | Manage Pages
- Select the Content Root page title
- Click New Label.
- Create a label called My Favorites.
- Assign privileged user access to all authenticated users.
- Click OK when you have finished.
- Click...
Portal Settings | Custom Unique Names
- Assign wps.My Favorites as a unique name to the My Favorites label you just created.
- Click OK when you have finished.
- Click...
Administration | Portal User Interface | Manage Pages
- Add a page parameter key of Favorites with a value of Yes.
- Add <portal-logic:if/> tags with the pageBookmarkable attribute set to true to pages that you want to be able to bookmark.
Improve the performance of themes
WebSphere Portal includes a lightweight theme that demonstrates some of the design features that you could omit for better performance.
Use WCM-managed IMG in Portal Theme
- Upload the image to image component.
- Use an RTE component or element to create a link to the image component
- Open the code view in the RTE
- Copy the url to the image. It should look like something like this...
/wps/wcm/myconnect/52346a00405832c59c67bc096aef9bce/mytheme.gif?MOD=AJPERES
- Use the url in your portal theme.
Parent topic
Customizing the portal
Related tasks
Importing a theme
Deploying the theme
Creating a new skin
Enabling automatic JSP reloading
Supporting new clients
Supporting new markup languages
Changing text information
Enabling the Organize Favorites portlet in themes
Related reference
Using the color palette in themes
Performance guidelines for themes and skinsRelated information
Changing the page help