Hi, I would like to use class fasttemplate to show a table with alternating color lines(say, one white one red, and so on)
I want the designer to control the colors, that's why I am trying to find a way to set the colors in the template...
I was thinking of something like:
<!-- NAME: form.tpl -->
{FORMOPEN}
<table>
<!-- BEGIN DYNAMIC BLOCK: row1 -->
<tr bgcolor="white">
<td>{LABEL}</td>
<td>{CODE}</td>
</tr>
<!-- END DYNAMIC BLOCK: row1 -->
<!-- BEGIN DYNAMIC BLOCK: row2 -->
<tr bgcolor="red">
<td>{LABEL}</td>
<td>{CODE}</td>
</tr>
<!-- END DYNAMIC BLOCK: row2 -->
</table></form>
<!-- END: form.tpl -->
That is, define two dynamic blocks, and parse them alternatily...
Here's the code I am using:
$tpl = new FastTemplate(TEMPLATES);
$tpl->define(
array(
form => "form.tpl"
)
);
$tpl->define_dynamic ( "row1", "form" );
$tpl->define_dynamic ( "row2", "form" );
$tpl->assign( array( FORMOPEN =>'<form blah blah>');
reset($this->fields);//this is an array with the field for the form
while(list($key,$val) = each($this->fields)) // get form fields
{
$r=($r=='.row1')?'.row1':'.row2';
$this->frmGenElement(0,$key,'');
$tpl->assign(
array(
LABEL => $this->buffLabel,
CODE => $this->buffCode
)
);
$tpl->parse(ROWS,$r);
}
$tpl->parse(MAIN, 'form');
$tpl->FastPrint();
Unfort. this is not working, I get strange behaviours.. :-|
I am no expert in fasttemplates... and can not figure it out...
Any hint?
TIA
Sergio