[phplib] Dynamic block fetching help From: Peter Bowyer (reywob <email protected>)
Date: 03/15/01

Hi,

I have the following code which I just can't get to work. I am trying to
get a block out of form.tpl, and from user input (in the form of $r = ?)
repeat the block as many times as needed. Please can someone tell me
what's wrong with the way I'm trying to do it?

Thanks,
Peter.

The PHP code

--
$tpl = new Template(".");
$tpl->set_file(array("form"=>"form.tpl", "card"=>"card.tpl"));
$tpl->set_block("form", "recipient_block", "recipient");
$num_recipients = $tpl->get_var("recipient");
$num = "";
for($i=0; $i<$r; $i++){
    $num .= $num_recipients;
//  $tpl->parse("recipient", "recipient_block", true);
}
$tpl->set_var("recipient", $num);
$tpl->set_var("IMAGE", $image);
$tpl->set_var("IMGSIZE", imgsize($image));
$tpl->set_var("CAPTION", $caption);
$tpl->set_var("TO", $to);
$tpl->set_var("TO_EMAIL", $to_email);
...
...
$tpl->parse("CONTENT", "form");
$tpl->pparse("CONTENT", "card");
--

Part of form.tpl: -- <!-- BEGIN recipient_block --> <tr> <td width="140">To:</td> <td width="80%"> <input type="text" name="to" value="{TO}"> </td> </tr> <!-- Leave the following line in place!!! --> {INVALIDTO_EMAIL} <tr> <td width="140">Email address</td> <td width="80%"> <input type="text" name="to_email" value="{TO_EMAIL}"> </td> </tr> <!-- END recipient_block --> -- --oOo-- Narrow Gauge on the web - photos, directory and forums! http://www.narrowgauge.f2s.com --oOo-- Peter's web page - Scottish narrow gauge in 009 http://members.aol.com/reywob/ --oOo--

--------------------------------------------------------------------- To unsubscribe, e-mail: phplib-unsubscribe <email protected> For additional commands, e-mail: phplib-help <email protected>