[PHPTAL] Nested repeat
Tomas Sirny
tsirny at gmail.com
Mon Mar 26 14:42:04 CEST 2007
Hello, I have one problem with using repeat in PHPTAL. I'm trying to
do something like this
<ul>
<li>one</li>
<ul>
<li>first</li>
<li>second</li>
</ul>
<li>two</li>
<ul>
<li>1</li>
<li>2</li>
</ul>
</ul>
but it ends with this:
<ul>
<li>one</li>
<li>two</li>
<ul>
<li>1</li>
<li>2</li>
</ul>
</ul>
Simply, it seems like only the last nested repeat has been executed
and it doesn't depend on number of first-level iterations, it's always
the last.
My code (test.html):
<ul >
<li tal:repeat="item archive">
<a tal:attributes="href item/href" tal:content="item/text">Link</a>
</li>
<ul>
<li tal:repeat="subitem item/subitem">
<a tal:attributes="href subitem/href"
tal:content="subitem/text">Sublink</a>
</li>
</ul>
</ul>
and
<?php
require_once 'PHPTAL.php';
class A {
public $href = "dfas";
public $text = "kkjkj";
}
class B {
public $text = "erer";
public $href = "tytyty";
public $subitem;
}
$b1 = new B();
$b1->subitem = array(new A(), new A());
$b2 = new B();
$b2->subitem = array(new A(), new A());
$b3 = new B();
$b3->subitem = array(new A(), new A());
$menu = file_get_contents('test.html');
$template = new PHPTAL();
$template->setSource($menu);
$template->archive = array($b1,$b2,$b3);
try {
echo $template->execute();
}
catch (Exception $e){
echo $e;
}
?>
Does someone see bug in my code? I have found in mailing list very
similar code as an advice.
Thanks for any help.
Tomas
More information about the PHPTAL
mailing list