What Is a Context?

As a CMS file is being exported, it serves as the data source for the layout with which the file is exported (e.g. the mastertemplate). This data source contains named values such as the title of the CMS file, accessible via title. Thus, the data source provides the context in which NPSOBJ instructions operate when they reference a name to retrieve its value:

<npsobj insertvalue="var" name="title" />

Here, the value of title in the current context is queried. If a context is queried for a value of a name unknown in this context, the empty value is returned.

The Content Management Server provides two context types, file and link contexts.

During the export of a file there are always at least two contexts, the initial and the current context. At the beginning of the export of a document or a folder, this CMS file provides both the initial and the current context. The initial context remains the same during the export of the CMS file. The current context, however, may change. The current context is changed by NPSOBJ instructions that do not yield a simple value such as title but a list of contexts. The following instructions return such a context list: list, newslist, table, and context.

By means of these instructions, NPSOBJ code can be executed for each context in the context list. An example:

<npsobj list="toclist">
  <npsobj insertvalue="anchor" name="self">
    <npsobj insertvalue="var" name="title" /><br />
  </npsobj>
</npsobj>

The 2nd-level NPSOBJ instruction, insertvalue="anchor", is executed for each context contained in toclist. In each cycle of the list instruction, the context taken from the toclist becomes the current context. After all toclist contexts have been processed, i.e. after the list instruction has finished, the original context in which the list instruction was executed becomes the current context again.

Every query for a value is evaluated in the current context. The list of names available in the current context depends on the context type. With file contexts, the names available in them largely result from the file type and the file format.