Contexts
WebCatalog introduces the term Contexts. We chose this term because it means that certain information is only available (or meaningful) within particular surroundings. For instance, the tag [Date] has meaning everywhere, and typically will display today's date like "12/16/1996". But the tag [NumFound] doesn't mean anything unless it's in the context of a database search -- WebCatalog cannot know what to display unless it first knows what database to search in and what exactly to look for. Once it knows these things, WebCatalog knows that [NumFound] should display the number of records which match 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.
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 whose name is "Grant" > [/Search] [NumFound] <-- has no meaning here (it's outside the [Search]) -------------------------------------
Every page (or template, as we call them) that WebCatalog displays is automatically inside of a context that gives 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. Certain commands, such as Search, also "wrap" a template inside of an implied context. Here are two HTML pages that show what we mean:
------- 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 > ------------------------------