RE: [PHP Template] Template Discussion
| From: | Peter Kocks | Date: | Wed, 22 Mar 2000 21:43:29 +0000 |
| Subject: | RE: [PHP Template] Template Discussion | ||
| References: | 1 | Groups: | php.template |
| Request: | Send a blank email to php-template+get-432@lists.php.net to get a copy of this message | ||
>
> The way you suggest doing it
> ----------------------------
> <? for($loop=0; $loop<=count($Name); $loop++): ?>
> <? print $Name[$loop]; ?><br>
> <? print $Address[$loop]; ?><br>
> <? print $Phone[$loop]; ?><p>
> <? endfor; ?>
>
No I propose using here docs to make this simpler.
<? for($loop=0; $loop<=count($Name);
op++){
print <<< ADDRESS;
$Name[$loop]<br>
$Address[$loop]<br>
$Phone[$loop]<p>
ADDRESS;
}
?>
Of course you could use the foreach call, which although undocumented, I believe is available in
php4.
And, a simple addition to the language of a template(filename) function that would add a here doc in
the same way as an include does today.
So the programmer would write:
<? for($loop=0; $loop<=count($Name); $loop++){
template("address.tmpl");
}
?>
Add the designer would write the file called address.tmpl:
$Name[$loop]<br>
$Address[$loop]<br>
$Phone[$loop]<p>
Note that function call could be added to the template file that the designer writes by using object
methods. As in:
$Name[$loop]<br>
$Address[$loop]<br>
$Phone[$loop]<p>
{$orders.table()}