pear template revoke problem
Hello,the phpers.i'm recently learn to use the pear HTML_Template_IT,
The following is my test template test.tpl,the source code is :
<html>
<table>
<!-- BEGIN CELL -->
<tr>
<td>
{DATA}
</td>
<!-- END CELL -->
</tr>
</table>
</html>
And my php revoke source code is :
<?php
require_once "HTML/Template/IT.php";
$data = array("Peter","Quagmire","Joe");
$tpl = new HTML_Template_IT("./template");
if (!$tpl) {
echo "object inital failed!";
echo "
";
}
else
print "Object initial succeed!
";
$tpl->loadTemplatefile("test.tpl", true, true) ;
if (!$tpl) {
echo "template load failed!";
echo "
";
}
else
print "template load succeed!
";
foreach ($data as $sd ){
//echo $sd;
//echo "
";
$tpl->setCurrentBlock("CELL");
$tpl->setVariable("DATA", $sd);
$tpl->parseCurrentBlock("CELL");
}
$tpl->show();
?>
When it runs it just result this :
Object initial succeed!
template load succeed!
i don't why the array data are not displayed?Any comments are appreciated !
All you best
------------------------
What we are struggling for ?
The life or the life ?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: pear template revoke problem
The problem resolved because the following line:
$tpl =3D new HTML_Template_IT("./template");
changed to :
$tpl =3D new HTML_Template_IT(".");
the .php works fine.
All you best
------------------------
What we are struggling for ?
The life or the life ?
On Tue, Jun 29, 2010 at 2:55 PM, win.a <win.acc [at] gmail.com> wrote:
> Hello,the phpers.i'm recently learn to use the pear HTML_Template_IT,
> The following is my test template test.tpl,the source code is :
> <html>
> <table>
> <!-- BEGIN CELL -->
> =C2=A0<tr>
> =C2=A0 <td>
> =C2=A0 =C2=A0{DATA}
> =C2=A0 </td>
> <!-- END CELL -->
> =C2=A0</tr>
> =C2=A0</table>
> </html>
>
> And my php revoke source code is :
> =C2=A0<?php
> =C2=A0 =C2=A0 =C2=A0 =C2=A0require_once "HTML/Template/IT.php";
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0$data =3D array("Peter","Quagmire","Joe");
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0$tpl =3D new HTML_Template_IT("./template");
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!$tpl) {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "object inita=
l failed!";
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "
";
> =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> =C2=A0 =C2=A0 =C2=A0 =C2=A0else
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0print "Object init=
ial succeed!
";
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0$tpl->loadTemplatefile("test.tpl", true, true)=
=C2=A0;
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!$tpl) {
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "template loa=
d failed!";
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0echo "
";
> =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> =C2=A0 =C2=A0 =C2=A0 =C2=A0else
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0print "template lo=
ad succeed!
";
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0foreach ($data as $sd =C2=A0){
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//echo $sd;
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0//echo "
";
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$tpl->setCurrentBl=
ock("CELL");
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$tpl->setVariable(=
"DATA", $sd);
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$tpl->parseCurrent=
Block("CELL");
> =C2=A0 =C2=A0 =C2=A0 =C2=A0}
> =C2=A0 =C2=A0 =C2=A0 =C2=A0$tpl->show();
> ?>
>
> When it runs it just result this :
>
> Object initial succeed!
> template load succeed!
>
> i don't why the array data are not displayed?Any comments are appreciated=
!
>
> All you best
> ------------------------
> What we are struggling for ?
> The life or the life ?
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php