Contexts
Any "container" of the form [ContextName]...[/ContextName]
 
Note: you have probably already used contexts in your day-to-day HTML design. HTML like "<b>This part is bold <i>this part is bold and italic</i>..back to just bold</b>" is an example of an italic context inside of a bold context.

WebCatalog introduces the term Contexts. We chose this term because it means that certain information is available (or meaningful) only within particular surroundings. For instance, the tag [Date] has meaning everywhere, and typically displays today's date as "12/16/1996." But the tag [NumFound] does not mean anything unless it is in the context of a database search -- WebCatalog cannot know what to display unless it first knows what database to search in and exactly what to look for. Once it knows these things, WebCatalog knows [NumFound] should display the number of records matching the search.

Certain tags (such as [date] and [time]) are always available and have meaning everywhere. We call these Global Tags. Other tags (such as [index] and [NumFound]) only make sense inside of certain contexts. In fact, [index] is available in many different contexts -- when used inside a [FoundItems] context it means the record number of the Nth found record, but when used inside a [Loop] context is means the number of iterations the loop has gone through.

You can put as many contexts into a page as you want, and contexts can be "nested" inside of each other.

Note: Computer programmers sometimes call this concept "Scope"

Here are some examples of tags in their contexts. Normally you would type this text into a .tpl file and use your web browser to view it on your web server.

------------ test.tpl -------------
[date] <!-- today's date, such as 12/16/1997 -->

[NumFound] <!-- has no meaning here -->

[Search db=xx.db&eqNAMEdata=Grant]
  [NumFound] <!-- displays number of records where the name is "Grant" -->
[/Search]

[NumFound] <!-- has no meaning here (it's outside the [Search]) -->
-------------------------------------

Every page (or template, as we call them) WebCatalog displays is automatically inside of a context providing meaning to certain tags. All of the information about the remote web browser, such as [BrowserName], [Username], [Password], is available, along with all of the form variables from a <form> submission, all the MIME headers, cookies, math variables, and text variables. Certain commands, such as Search, also "wrap" a template inside of an implied context. Here are two example HTML pages:

------- SearchForm.html ---------
<form method=POST action=Results.tpl>
<input type=hidden name=command value=Search>
<input type=hidden name=db value=xx.db>
Search for: <input name=eqNAMEdata>
<input type=hidden name=extraStuff value="Hello">
<input type=submit>
</form>
----------------------------------

Clicking the submit button leads to the following page:

------- Results.tpl --------
[Date] <!-- always available -->

[extraStuff] <!-- any form variable can be displayed -->

[NumFound] <!-- works because we got to this page as a result of
               a Search command, which puts a [Search] context
               around this entire page -->

[FoundItems] <!-- only available inside a Search context -->
[NAME] <!-- field from a database only available inside FoundItems -->
[/FoundItems]

[eqNAMEdata] <!-- looks funny, but this really is the name of a
                 form variable from the previous form -->
------------------------------