Template::ifThenElse - jcobban/Genealogy GitHub Wiki
Up: class Template
This is a convenience function that uses the capabilities of class TemplateTag to implement the behavior of an if/then/else to select portions of the template to display. For example given a portion of a template that looks like:
<span id='istrue'>HTML to display if expression is true</span>
<span id='isfalse'>HTML to display if expression is false</span>
$template->ifThenElse($boolean, 'istrue', 'isfalse');
displays the contents of the tag with id='istrue' if the value of $boolean is interpreted as true
by PHP, or the contents of the tag with id='isfalse' if the value of $boolean is interpreted as false
by PHP.
This method has three parameters:
parameter | description |
---|---|
$expression | an expression which evaluates to a value which can be interpreted by a PHP as either true or false . |
$thenid | a string containing the value of the id attribute of the tag whose contents are retained in the Document Object Model (DOM) if the value of $expression is true . |
$elseid | a string containing the value of the id attribute of the tag whose contents are retained in the Document Object Model (DOM) if the value of $expression is false . |
Next: $template->debug