PHP Pear ITX add and replace block file
I use PEAR ITX to add template. What my problem is, first 2 time ($number>2) condition match and the $fileName2 is added success, block show as expect; but when the third time ($number==2) condition match but $fileName1 seem like fail to load, it doesn't show any thing. Here is my sample code:
$template = new HTML_Template_ITX("./templates");
$template->loadTemplatefile($maintemplate,true,true);
while($row = mysql_fetch_array($result))
{
if($number==2)
{
$template->addBlockFile("CANDIDATES","CAN",$fileName1);|
$template->setCurrentBlock("CAN");
//do anything i need
}else if($number>2) //first 2 times condition match, everything works well
{
$template->addBlockFile("CANDIDATES","CAN",$fileName2);
$template->setCurrentBlock("CAN");
//do anything i need
}
$template->setCurrentBlock("MAIN");
$template->parseCurrentBlock();
}
The situation can be contrary, if first 2 times condition match ($number==2), then the third time condition match ($number>2) but the problem still the exist.
What i found is the replaceBlockfile(), i tried but doesn't work. Anyone can tell me what wrong is it? Thank you.
Answer
Solution:
Seem like no one can answer my question, but i had figure out the problem. In my question, every times loop is using the same $template, because of $template outside the loop. What I need to do is put the:
inside the while loop, it is mean every time it loop will create a "NEW" table.