Multiple if condition in template code – Adobe Dreamweaver CS3 User Manual

Page 398

Advertising
background image

DREAMWEAVER CS3

User Guide

391

field reference (the “dot” operator)

unary operators: +, -, ~, !

binary operators: +, -, *, /, %, &, |, ^, &&, ||, <, <=, >, >=, ==, !=, <<, >>

conditional operator: ?:

parentheses: ()

The following data types are used: Boolean, IEEE 64-bpc floating point, string, and object. Dreamweaver templates
do not support the use of JavaScript “null” or “undefined” types. Nor do they allow scalar types to be implicitly
converted into an object; thus, the expression

"abc".length

would trigger an error, instead of yielding the value 3.

The only objects available are those defined by the expression object model. The following variables are defined:

_document

Contains the document-level template data with a field for each parameter in the template.

_repeat

Only defined for expressions which appear inside a repeating region. Provides built-in information about

the region:

_index

The numerical index (from 0) of the current entry

_numRows

The total number of entries in this repeating region

_isFirst

True if the current entry is the first entry in its repeating region

_isLast

True if the current entry is the last entry in its repeating region

_prevRecord

The

_repeat

object for the previous entry. It is an error to access this property for the first entry in the

region.

_nextRecord

The

_repeat

object for the next entry. It is an error to access this property for the last entry in the

region.

_parent

In a nested repeated region, this gives the _repeat object for the enclosing (outer) repeated region. It is an

error to access this property outside of a nested repeated region.

During expression evaluation, all fields of the _document object and _repeat object are implicitly available. For
example, you can enter

title

instead of

_document.title

to access the document’s title parameter.

In cases where there is a field conflict, fields of the _repeat object take precedence over fields of the _document
object. Therefore, you shouldn’t need to explicitly reference _document or _repeat except that _document might be
needed inside a repeating region to reference document parameters that are hidden by repeated region parameters.

When nested repeated regions are used, only fields of the innermost repeated regions are available implicitly. Outer
regions must be explicitly referenced using _parent.

Multiple If condition in template code

You can define template expressions for if and multiple-if conditions. This example demonstrates defining a
parameter named "Dept", setting an initial value, and defining a multiple-if condition which determines which logo
to display.

The following is an example of the code you might enter in the

head

section of the template:

<!-- TemplateParam name="Dept" type="number" value="1" -->

The following condition statement checks the value assigned to the

Dept

parameter. When the condition is true or

matches, the appropriate image is displayed.

September 4, 2007

Advertising