Date: 01/17/01
- Next message: Ulf Wendel: "[phplib] [Fwd: [PHP-PEAR] Merging PHPLIB into PEAR]"
- Previous message: Bertrand Mansion: "Re: [phplib] Pure Template"
- In reply to: Bertrand Mansion: "Re: [phplib] Pure Template"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Bertrand Mansion wrote:
> Zakaria,
> > Basicly it work like the PHPLib Template without the block stuff
> > because you could use normal php in the template. Also you could put
> > some filter (regexp replace) to the output.
> I don't really understand what your template class is supposed to do ?
> Could you please explain. How do you replace the block features which are
> very useful ?
Well, it's for people who need template that has some conditional in
there.
And because it use php template mechanism I think (haven't checked)
it should work faster than PHPLib Template. It doesn't need block
feature
because the template file itself is a regular php file. So you just
set_var("arrayvar", $array_value) and use foreach or while block in your
template.
Why not just include() or required() the files?
Sometime you need to make output bit by bit and print it out when
everything (DB Call, Parameter Check, etc) goes fine and when it doesn't
you want to print some error page instead some half backed output.
Some sample might clear the confusion:
Here the php code:
===========================================================
<?php
include("template.inc");
$tpl = new Pure_Template();
$tpl->set_file("simple", "sample.ihtml");
$tpl->set_var("Title", "Testing New Template");
$tpl->set_var("self", $PHP_SELF);
$tpl->set_var("email", "me <email protected>");
$tpl->set_var("ONE", $one);
$tpl->set_var("TWO", $two);
$tpl->set_var("THREE", $three);
$tpl->set_var("SHOW_FORM", !$hide);
$tpl->parse("out", "simple");
$tpl->p("out");
?>
===========================================================
And the corresponding template:
===========================================================
<html><head><title><? echo $Title ?></title></head>
<body bgcolor="white">
<h1><? echo $Title ?></h1>
<hr>
<form action="<? echo $self ?>" method="get">
<? if ($SHOW_FORM): ?>
<input type="checkbox" name="one"
<? if ($ONE): ?>checked<? endif ?>>One<br>
<input type="checkbox" name="two"
<? if ($TWO): ?>checked<? endif ?>>Two<br>
<input type="checkbox" name="three"
<? if ($THREE): ?>checked<? endif ?>>Three<br>
<input type="submit" name="action" value="Action">
<input type="submit" name="hide" value="Hide Form">
<input type="reset" value="Default">
<? else: ?>
<input type="hidden" name="one" value="<? echo $ONE ?>">
<input type="hidden" name="two" value="<? echo $TWO ?>">
<input type="hidden" name="three" value="<? echo $THREE ?>">
<input type="submit" name="show" value="Show Form">
<? endif ?>
</form>
<? if ($ONE): ?>
<ul>
<li>One: <? echo $ONE ?>
<li>Another One text
<? if ($TWO): ?>
<ul>
<li>Two: <? echo $TWO ?>
<li>Another Two text
<? if ($THREE): ?>
<ul>
<li>Three: <? echo $THREE ?>
<li>Another Three text
</ul>
<? endif ?>
</ul>
<? endif ?>
</ul>
<? endif ?>
<hr>
<address><a href="mailto:<? echo $email ?>"><? echo $email
?></a></address>
</body>
</html>
===========================================================
> Thank you
> Bertrand
Wassallam,
-- Zakaria
Work: zakaria <email protected>, http://asia-karsa.com
Private: z4k4ri4 <email protected> Yahoo!: z4k4ri4
http://pemula.linux.or.id
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>
- Next message: Ulf Wendel: "[phplib] [Fwd: [PHP-PEAR] Merging PHPLIB into PEAR]"
- Previous message: Bertrand Mansion: "Re: [phplib] Pure Template"
- In reply to: Bertrand Mansion: "Re: [phplib] Pure Template"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

