Author Topic: Control structure: TMPL_IF  (Read 1858 times)

0 Members and 1 Guest are viewing this topic.

Offline ClausVB

  • Administrator
  • Hero Member
  • *****
  • Posts: 566
    • Homepage: clausvb.de
Control structure: TMPL_IF
on: Thu, 05. April 2007 - 06:37:46
TMPL_IF: http://lamp.clausvb.de/vlib_examples/tmpl_if.php

deutsche Dokumentation: TMPL_IF mit Boolean und Konstanten

Code: [Select]
<?php
    
require_once vlib/vlibTemplate.php;

    
$tmpl = new vlibTemplate(tmpl/tmpl_if.htm);

    
$boolean = (isset($_GET[if_condition])) ? 0;

    
$tmpl->setvar(boolean$boolean);
    
$tmpl->setvar(if_condition$_GET[if_condition]);

    
$tmpl->pparse();
?>

Code: [Select]
<!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>&lt;p>This text is gray without "if_condition" set. Click
&lt;a href="tmpl_if.php?if_condition=1">here&lt;/a> to make it purple.
<span style="color: red">&lt;tmpl_if name=if_condition op=> value=5></span>
   &lt;span style="color: green">"if_condition" is more than 5.&lt;/span>
<span style="color: red">&lt;tmpl_else></span>
   "if_condition" is not set or below (equal to) 5.
<span style="color: red">&lt;/tmpl_if></span>&lt;/p></pre>

</body>
</html>
Last Edit: Sat, 07. April 2007 - 12:08:53 by ClausVB