Compass Server 3.0 Developer's Guide

[Contents] [Previous] [Next] [Last]

Chapter 2
Templates for the End User Page

Each time a user clicks a category name or submits a search in the Compass Server End User page, the system completely redraws the page, using either browse or search-results mode, depending on what action the user took.

The appearance of the Compass Server End User page is not only governed by which mode it uses, but also by the UI template that is currently selected for use.

The Compass Server comes with a set of pre-defined templates, and you can also create your own. You can specify which template is currently in use by choosing the desired template from the Template menu in the End User screen of the Compass Server Administration environment.

Each template consists of a configuration file and a set of pattern files. The configuration file defines which pattern files to use for which components in the browse mode and search-results modes. Each pattern file contains HTML and/or JavaScript code that defines the content of the component. Pattern files can use special variables to access data such as the number of matches in the current search query, which category was being searched, and so on.

For example, the configuration file for the "Normal" template is called normal.conf. This configuration file has code that specifies which pattern files define which components in pages that use this template. For example, the browse-top component of the End User page is defined by the normal-bw-top.pat pattern file; the category-browse-top component is defined by the normal-cb-top.pat pattern file; the category-browse-hit component is defined by the normal-cb-hit.pat file; and so on.

To create a new template, you can copy and rename an existing configuration file. Edit the configuration file and specify which pattern files it uses. You can use existing pattern files, or you may want to create new ones, by copying and modifying existing ones. You can then modify the pattern files to suit your needs, using HTML or JavaScript.

The configuration file and all pattern files in a template must live in the templates directory for the Compass Server. If you create additional configuration and pattern files, you can make them available to the Compass Server simply by putting them in the templates directory.

Saving and Applying Changes to UI Templates

This section describes the mechanics of creating and modifying templates, and loading the changed files into the Compass Server. You will learn more about the details of editing configuration and pattern files in the following chapters.

Creating a New Template

To create a new template, copy an existing configuration file and rename it to something that ends in .conf. Open the file in your favorite text editor and change the value of the RDM-description variable at the top of the file to a description of your new template. (This description will appear in the Template menu of the End User screen of the Compass Server Administration environment.)

Change the values of variables in the configuration file as appropriate. See the section "Configuration Files for UI Templates" for a discussion of these variables. Save the configuration file.

Copy and modify any pattern files as needed. See the section "Pattern Files for UI Templates" for a discussion of pattern files. Save the changes.

Make sure that the configuration file and all pattern files that it uses are saved in the templates directory of the server that will be using the template.

Selecting a New UI Template

In the Compass Server Administration environment, go to the End User screen, by selecting the End User button on the Administration page for the appropriate server.

In the "Search/Browse Preferences" section, select the desired template from the Template menu. Press the OK button. You will also need to press the Apply button at the top of the page, and press the "Apply Changes" button that subsequently appears.

If the new template uses files that were not previously loaded, or have been modified since they were last loaded, you will also need to load the configuration files.

Loading Updated Template Files

Before you create or modify configuration and pattern files, you need to change the value of the template-refresh-rate variable in the csid.conf file. This file lives in the config directory of the directory containing the specific Compass Server. For example, suppose you have installed Compass Server 3.0 in compassdir, and have created a server instance named topper. In this case, the csid.conf file will be in:

compassdir/compass-topper/config/csid.conf
The template-refresh-rate variable tells the Compass Server how often (in seconds) to update the templates used by the End User page.

Set this to a low value such as 1:

template-refresh-rate=1
This tells the Compass Server to refresh the UI template once every second. This ensures that the Compass Server End User page uses the latest versions of the configuration and pattern files as you make changes to them.

Save the change. Open the Compass Server Administration environment (if it is not already open), and go to the Administration page for the appropriate server.

From any page in the Administration page of the appropriate server, you can press the Apply button at the top of the page. The main frame updates to show the "Apply Changes" frame, which includes a button labelled "Load Configuration Files." Press this button to load the changed csid.conf file. The next time you use the Compass Server End User page, you should see that the changes have taken effect.

You only need to change and load the csid.conf file once. From then on, any changes you make in the configuration or pattern files used by the currently selected template should automatically appear the first time you search or browse after making the changes.

Hint: If your changes do not appear automatically, make sure you set the template-refresh-rate variable in the directory compassdir/compass-name/config/, not in the compassdir/bin/compass/config/ directory.

When you have finished developing templates, you should set the template-refresh-rate variable to a value such as 3600 so that the Compass Server does not waste time updating its UI template each time a user uses the End User page.


[Contents] [Previous] [Next] [Last]

Last Updated: 02/07/98 20:49:01

Any sample code included above is provided for your use on an "AS IS" basis, under the Netscape License Agreement - Terms of Use