[dev] Horde templates short examples
Mike Cochrane
mike at graftonhall.co.nz
Fri Dec 20 11:04:57 PST 2002
Here's a couple more to add to your collection
IF-ELSE CONDITIONS
----
PHP:
// the first true is the values set to the variable
// the second true indicates it is going to be used in an if statement.
$template->set('somename', true, true);
TEMPLATE:
<html><body>
welcome to our site...<br />
<if:somename>
somename is true
<else:somename>
somename is false
</else:somename>
</if:somename>
</body></html>
** Note: the <else> statement must be enclosed in the <if> block.
IF CONDITIONS AND ARRAYS
----
PHP:
// the first true is the values set to the variable
// the second true indicates it is going to be used in an if statement.
$users = array('john', 'peter', 'mary');
$template->set('users', $users, true);
TEMPLATE:
<html><body>
welcome to our site...<br />
<if:users>
Current users:<br/>
<loop:users>
<tag:users /><br/>
</loop:users>
<else:users>
There are no users at the moment
</else:users>
</if:users>
</body></html>
** Note: the <else> statement must be enclosed in the <if> block.
More information about the dev
mailing list