English support > vLIB examples
Control structure: TMPL_IF
(1/1)
ClausVB:
TMPL_IF: http://lamp.clausvb.de/vlib_examples/tmpl_if.php
deutsche Dokumentation: TMPL_IF mit Boolean und Konstanten
--- Code: ---<?php
require_once vlib/vlibTemplate.php;
$tmpl = new vlibTemplate(tmpl/tmpl_if.htm);
$boolean = (isset($_GET[if_condition])) ? 1 : 0;
$tmpl->setvar(boolean, $boolean);
$tmpl->setvar(if_condition, $_GET[if_condition]);
$tmpl->pparse();
?>
--- End code ---
--- Code: ---<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>tmpl_if</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
body
{
font-family: Arial;
font-size: 0.9em;
color: <tmpl_if name=boolean>purple<tmpl_else>gray</tmpl_if>;
}
pre { color: black; font-size: 1.1em; }
</style>
</head>
<body>
<p>This text is gray without "if_condition" set. Click <a href="tmpl_if.php?if_condition=1">here</a> to
make it purple. <tmpl_if name=if_condition op=> value=5><span style="color: green">"if_condition"
is more than 5.</span><tmpl_else>"if_condition" is not set or below (equal to) 5.</tmpl_if></p>
<pre><p>This text is gray without "if_condition" set. Click
<a href="tmpl_if.php?if_condition=1">here</a> to make it purple.
<span style="color: red"><tmpl_if name=if_condition op=> value=5></span>
<span style="color: green">"if_condition" is more than 5.</span>
<span style="color: red"><tmpl_else></span>
"if_condition" is not set or below (equal to) 5.
<span style="color: red"></tmpl_if></span></p></pre>
</body>
</html>
--- End code ---
Navigation
[0] Message Index
Go to full version