Reference
JavaScript Code Library
XSSI if, elif, and else directives
These so-called flow-control
elements allow you to make documents display differently depending on the
value of variables (such as which browser is being used or the time of day or
whatever).
Basic
syntax:
<!--#if expr="text_expression" -->
do what's here
<!--#elif expr="text_expression" -->
do this instead
<!--#else -->
do this one
<!--#endif -->
How to insert a new if directive
The "Insert XSSI if"
dialog has a listing of all the if directives that will be added to the document.
Only the directives will be added - the content has to be inserted later through
the document window of Dreamweaver or through the HTML inspector.
You can add directives to the block
by using the
button. This will add a new elif directive to the block directly after the currently
selected directive. You may remove the selected elif or else directive by clicking
the
button (you cannot remove the if or endif because these are required). The up
and down arrows
are used to reorder the directives in the current block. Any directive moved
to the top automatically becomes the if directive, while an if directive moved
to the middle of the block automatically becomes an elif. To change an elif
directive to an else you check the checkbox that appears when the last elif
directive in the block is highlighted. You cannot reorder
an else or endif directive.
The "Browser" menu will
be displayed by default. In this mode, you can specify conditions for each if
or elif directive to match certain types of browsers. To do so, select a browser,
version, and platform using the pulldown menus.
Advanced patterns
If you need to do something more complex, you can use either "Basic"
or "Advanced" modes by selecting the appropriate tab at the top of
the dialog box. In Basic mode, you can construct a basic match against variables
that have been set in your document, or environmental
variables that you have specified. This mode will allow you to set any expression
that can be broken down into the following basic syntax: a declared variable,
one of the supported operators (=,!=,>,>=,<,<=, or simply test whether
or not the variable exists), and the value to match against (expressed as a
regular expression).
If the expression you need is more
complex - such as a combination of two or more separate expressions - the Advanced
mode will be necessary. This mode simply provides a text box in which you can
edit the actual contents of the expression directly. You can switch to the advanced
view by clicking the "Advanced" tab.
When you click "OK", the
directives you have created will be inserted into your document. You will see
something like the following:
{ if content goes here }
elif content goes here }
elif content goes here }
Or, if automatic
translation of XSSI content is enabled, you will see something like this:
{ elif content goes here }
The text between (and including)
the curly braces is editable and should be replaced with the content that you
want displayed when the directive that surrounds it is true. Once the page is
translated, you will see a maximum of one directive from any block at a time
(since only one can be true at any given time).
Editing if directives in your
document
To move through the block of if directives in your document, just select any
of the invisibles icons
that are part of the block. This will bring up the if block property inspector,
which looks like this:
From the inspector, you can modify
the current directive in much the same way as when you first inserted it. There
are the same three modes (browser, basic, and advanced), which are automatically
selected according to the type of expression in the directive, but which can
also be selected manually through the tab interface. The inspector can also
be used to navigate the if block: Clicking the prev and next buttons
will take you to the next appropriate if directive, and, if the document has
been translated, it will make that portion of the if block visible (as if the
expression were true) and available for editing.
For more information about using
if, elif, and else directives (and XSSI in general),
take a look at this introduction
to XSSI.
|