Using Variables
Each special variable starts with $$
, for example, $$RDM-Hits-Searched
. See Attributes derived from the Compass Database Schema for a full list of the variables.
You can use the pre-defined variables in three ways:
Use the variable name by itself to evaluate to the variable's value. For example, the
following code displays a table cell that shows the title of a document. $$var
$$url
is the
URL of the document, $$title
is the title of the document, and $$description
is the description.
<td valign=top align=left width=90%>
<a href="$$url"><b>$$title</b></a>
<BR> $$description
</td>
If the variable name is followed by a single set of square brackets, the contents of the
brackets are displayed or evaluated only if the named variable has a value. Basically
this syntax is shorthand for "if $$var has a value, then do the code in square
brackets."
For example, the following code uses the variable If $$var[do this if $$var is defined]
$$rdm-scope
, which evaluates to
the text for which the user is searching. If the user did not submit a search, then
$rdm-scope
has no value. If $$rdm-scope
has a value, (for example, "springer
spaniel"), then this code prints a paragraph such as "Search results for springer
spaniel:"
$$rdm-scope
has no value, nothing is displayed.
$$rdm-scope[<P>Search results for <I>$$rdm-scope:</I></P>]
If the variable name is followed by two sets of square brackets, the contents of the
first set of brackets are displayed or evaluated only if the named variable has a value.
The contents of the second set of brackets are displayed or evaluated if the named
variable does not have a value. (Note that if the variable's value is 0 or false, the
variable is considered to have a value.)
Basically this syntax is shorthand for "if $$var has a value, then do the code in the
first set of square brackets, otherwise do the code in the second set of square
brackets."
For example, the following code uses the variable If $$var[do this if $$var is defined][do this if $$var is not defined]
$$rdm-scope
, which evaluates to
the text for which the user is searching. If the user did not submit a search, then
$rdm-scope
has no value. If $$rdm-scope
has a value, (for example, "australian
shepherd"), then this code prints a paragraph such as "Search results for australian
shepherd:"
$$rdm-scope
has no value, the message "No search submitted" is displayed.
$$rdm-scope[<P>Search results for <I>$$rdm-scope:</I></P>]
[<P>No search submitted</P>]
$$RDM-rotated-color
variable is drawn from a list that is defined in the configuration file. Other variables give you information about the current environment, or what the user is doing, for example $$category
variable tells you what category the user is currently browsing, while the $$RDM-scope
variable tells you what text the user was using as their search criteria.
Yet other variables reveal data that is stored in the Compass Server's database. Each entry in the database is known as a resource description (RD). Each resource description contains data about a resource, such as a web page, on the network. Each resource description has multiple attributes or fields. These attributes are known as SOIF attributes, where SOIF stands for Summary Object Interchange Format.
A SOIF attribute is an attribute whose value is derived from a field in the database. For each SOIF attribute, there is a $$
variable that directly corresponds to that attribute. For example, each resource description has attributes Description and Title, consequently you can use the variables $$description
and $$title
.
Some of these SOIF attributes are fairly standard, such as description and title. However, developers can set up the schema of their database however they like.
When editing the schema of your database (as discussed in the "Compass Server Administrator's Guide"), you can add new attributes or delete existing attributes. When the robot finds a resource, such as an HTML file, to be indexed, it needs to know how to get the data to assign to each attribute for storage in the database. The most common way to map resource data to database attributes is through the use of the META tag. That is, the robot looks for a META tag whose name is the same as the attribute, and if it finds such a tag, the robot takes the content of the tag and uses it as the value of the attribute in the database.
Anyway, as you can see, the precise list of $$
SOIF-attribute
variables varies from database to database, depending on the schema of the database.
$$
variables you can use in your pattern files. The variables are presented in tables categorized by use.
Table 4.1. Attributes derived from the Compass Database Schema
<BODY>
tag for the whole page. You can set background color, link color, text color and so on for the whole page by specifying appropriate attributes for the <BODY>
tag. For a list of all the attributes for the <BODY>
tag see the entry for BODY in the HTML Tag Reference.
The top pattern files should also define the title for the Compass End User Page (that is, they should have a <TITLE>
tag.) These files should also include any desired META
tags or other tags that need to go between <HEAD>
and </HEAD>
.
Top pattern files often contain a text field for search criteria. If you want both browse-mode and search-results mode pages to show the text field, then you must include the text field in the pattern files for both the browse-mode-top and search-mode-top components. (For information about defining forms that have text entry field for search criteria, see Using Forms to Submit Searches.)
If you want the Compass Server End User page to display a logo for your company, instead of, or as well as, the Compass Server logo, you need to put the logo in the top pattern files.
category-browse-top and category-search-results-top
The pattern file for the category-browse-top component defines the introduction to the list of categories in the browsed category. The pattern file for the category-search-results-top component defines the introduction to the list of categories that match the search criteria when a search was submitted. These files are known collectively in this section as category-top files.
If you want the subcategories or matching categories to be displayed in a structure such as a table or list, you can define the opening tag, such as <TABLE>
or <UL>
in the category-top files.
Table 4.3. Variables for Use in Top Pattern Files only lists some variables that may be useful in category-top pattern files. The page-related variables, as discussed in Table 4.5 may also be useful in category-top files. Additionally, the following variables may be useful:
category-browse-hit and category-search-results-hit
The pattern file for the category-browse-hit component is invoked for each sub-category in the browsed category. The pattern file for the category-search-results-hit component is invoked for each category that matches the search criteria when a search was submitted. This section refers to these pattern files collectively as category-hit files.
You can define category-hit files to display the information about the category being processed. If the corresponding category-top file started a list, then you should display each category as a list item. If the corresponding category-top file started a table, then you should display each category as a table row. You can, if desired, set the background of each row to $$RDM-rotated-color
so that the table uses alternating colors for the rows. For more details, see Determining What Colors to Use for Documents and Categories.
Variables that may be useful in category-hit files include:
category-browse-bottom and category-search-results-bottom
The pattern file for the category-browse-bottom component defines the content that follows the list of subcategories in a browse-mode page. The pattern file for the category-search-results-bottom component defines the content that follows the list of categories that matched the search criteria when a search was submitted. This section refers to these two files collectively as category-bottom files.
If a category-top file start a structure such as a table or list, the corresponding category-bottom file must close that structure, for example by writing a </TABLE>
or </UL>
tag.
document-browse-top and document-search-results-top
The pattern file for a document-browse-top component defines the introduction to the list of documents in a browsed category. The pattern file for a document-search-results-top component defines the introduction to the list of documents returned by a search submission. These two pattern files are referred to collectively in this section as document-top files.
If you want to display the documents in a structure such as a table or a list, you can define the opening tag, for example <TABLE>
or <OL>
in the document-top files.
Table 4.3. Variables for Use in Top Pattern Files only lists some variables that can be useful in document-top pattern files. The page-related variables, as discussed in Table 4.5, can also be useful in document-top files. Additionally, the following variables may be useful:
$$Browse-Category | The category that the user is browsing. |
$$Search-Category | The category that the user is searching. |
$$RDM-Scope | The string that was submitted as the search criteria. |
document-browse-hit and document-search-results-hit
The pattern file for the document-browse-hit component is executed once for each document in the browsed category. The pattern file for the document-search-hit component is executed once for each document that matches the search criteria when a search has been submitted. These pattern files are referred to collectively in this section as document-hit files.
Usually document-hit files write the data about the document currently being processed.
You can define the document-hit files to display the documents however you like. However, it is common practice to display them in a table, with each document displayed in its own row, where each row has one cell that shows the ranking icon (if applicable) and one cell that shows the document description. You can, if desired, set the background of each row to $$RDM-rotated-color
so that the table uses alternating colors for the rows. For more details, see Determining What Colors to Use for Documents and Categories.
To retrieve information about a document, you can use the SOIF variables, as discussed in Table 4.1. Attributes derived from the Compass Database Schema.
Other variables that may be useful in document-hit files include:
document-browse-bottom and document-search-results-bottom
The pattern file for the document-browse-bottom component writes concluding remarks at the bottom of the list of documents in a browsed category. The pattern file for the document-search-results-bottom component writes the concluding remarks at the bottom of the list of documents returned by a search submission. These files are known collectively as document-bottom files in this section.
Often these files do nothing, or they write closing tags such as </TABLE>
or </OL>
that were opened in the corresponding document-top components. If the document-top files open structures such as tables or lists, you must close these structures in the corresponding document-bottom files.
browse-bottom and search-results-bottom
The pattern files for the browse-bottom and search-results-bottom components define the content that appears at the bottom of browse-mode and search-results mode pages as appropriate.
Since these files end the page, they should include </BODY>
and </HTML>
tags.
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