3.2. data and field
The [data] and [field] tags access elements of Interchange databases. They are the form used outside of the iterating lists, and are used to do lookups when the table, column/field or key/row is conditional based on a previous operation.
The following are equivalent for attribute names:
table --> base col --> field --> column key --> code --> row
The [field] tag looks in any tables defined as ProductFiles, in that order, for the data and returns the first non-empty value. In most catalogs, where ProductFiles is not defined, i.e., the demo, [field title 00-0011] is equivalent to [data products title 00-0011]. For example, [field col=foo key=bar] will not display something from the table "category" because "category" is not in the directive ProductFiles or there are multiple ProductFiles and an earlier one has an entry for that key.
[data table column key]
named attributes: [data base="database" field="field" key="key" value="value" op="increment]
Returns the value of the field in any of the arbitrary databases or from the variable namespaces. If the option increment=1 is present, the field will be automatically incremented with the value in value.
If a DBM-based database is to be modified, it must be flagged writable on the page calling the write tag. For example, use [tag flag write]products[/tag] to mark the products database writable.
In addition, the [data ...] tag can access a number of elements in the Interchange session database:
accesses Accesses within the last 30 seconds arg The argument passed in a [page ...] or [area ...] tag browser The user browser string host Interchange's idea of the host (modified by DomainTail) last_error The last error from the error logging last_url The current Interchange path_info logged_in Whether the user is logged in via UserDB pageCount Number of unique URLs generated prev_url The previous path_info referer HTTP_REFERER string ship_message The last error messages from shipping source Source of original entry to Interchange time Time (seconds since Jan 1, 1970) of last access user The REMOTE_USER string username User name logged in as (UserDB)
Databases will hide variables, so if a database is named "session," "scratch," or any of the other reserved names it won't be able to use the [data ...] tag to read them. Case is sensitive, so the database could be called "Session," but this is not recommended practice.
[field name code]
named attributes: [field code="code" name="fieldname"]
Expands into the value of the field name for the product as identified by code found by searching the products database. It will return the first entry found in the series of Product Files in the products database. If this needs to constrained to a particular table, use a [data table col key] call.