TT Web Site Manager Item management: Conditional items
Item management: Conditional items

The TT Web Site Manager supports a simple one layer conditional item as well as the normal PHP conditionals that can be used in PHP items. In a PHP file you might do something like this:

if ($thing_that_matters == "true"){
?>
<h1>Do this bit of HTML code</h1>
<?
}

Now imagine that you wanted to process a load of TT Web Site Manager items if your condition was true instead. Unfortunately it is impossible to extend a PHP conditional between TT Web Site Manager items so the TT Web Site Manager has a built in conditonal format of its own. First, you create a conditional start item containing your conditional code, then you put the items you wish to process if your conditional code is true after the conditional item, and finally you terminate it all with a conditional end item. An example extract from a page contents is shown below.

Sort order Item name Action
is form action delete?
delete news SQL
Conditional end

Here the conditional item checks to see whether a form variable contains the string "Delete story", and allows the TT Web Site Manager to move on to the next item which executes an SQL query to delete a line from a database if "Delete story" has been returned. The conditional end item tells the TT Web Site Manager that it is back to business as usual at the end of the conditional block. These conditionals suffer only one drawback, they can not be nested.

A typical conditional item is shown below. The code is simply a PHP conditional expression.

Item name
Container
Type

Enter a valid PHP expression here, E.G. $action == "Save". Please note that these conditional blocks can not be nested, if you need nested conditionals use a PHP code item instead.
Conditional expression

You should not need to create more than one conditional end item, they are all identical since they contain no code of their own. A conditional end item is shown below.

Item name
Container
Type

This item is the end of a conditional block. No code input is required here

Item management: SQL query items Contents The SQL prompt