Re: PEAR Template IT-X displaying 2 columns of data
| From: | David Soria Parra | Date: | Tue, 14 Nov 2006 12:21:20 +0000 |
| Subject: | Re: PEAR Template IT-X displaying 2 columns of data | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-25824@lists.php.net to get a copy of this message | ||
Hi
> Like this?
>
> 1 2 3 4 5 6
> I am able to display tables only on a single row..
>
> foreach ($fonts as $name) {
>> $tpl->setCurrentBlock('row');
>> $tpl->setVariable('ID', $name['id']);
>> $tpl->setVariable('LANGUAGE', $name['language']);
>> $tpl->setVariable('NAME', $name['name']);
>> $tpl->setVariable('DESC', $name['desc']);
>> $tpl->setVariable('_SIDE', $font_side_name);
>> $tpl->parseCurrentBlock('row');
>>
>> }
You have to do something like:
--- TEMPLATE.tpl ---
<!-- BEGIN row --><!-- BEGIN col -->{NAME} <!-- END col -->
<!-- END row -->"
--- SOURCE.php ---
<?php
require_once("HTML/Template/IT.php");
$tpl = new HTML_Template_IT(".");
$tpl->loadTemplatefile("TEMPLATE.tpl", true, true);
$fonts = array(1,2,3,4,5,6);
foreach ($fonts as $name) {
$tpl->setVariable("NAME", $name);
$tpl->parse("col");
if (++$i%2 == 0) {
$tpl->parse("row");
}
}
$tpl->show();
---- RESULTS -----
1 2
3 4
5 6
-------------------
If you want HTML Template IT not to create newlines dont add them to the
templatefile so do something like:
<!-- BEGIN foo -->my {CONTENT}<!-- END foo-->
and NOT
<!-- BEGIN foo -->
my {CONTENT}
<!-- END foo-->
Greets
David