Le samedi 09 août 2008 à 10:22 +0200, Guillaume Lecanu a écrit :

> Hi,
> 
> I have just tried your example.
> 
> Here is my list attached to PHPTAL :
> 
> $tpl->set('listmenu', array(
>         array('title' => 'First', 'submenu' => null),
>         array('title' => 'Second', 'submenu' => array(
>             array('title' => 'Youpiiii', 'submenu' => null),
>         )),
>         array('title' => 'Third', 'submenu' => null),
>     ));
> 
> 
> If I try to show the first level menus (first, second, third) this
> works fine with this code :
> 
>             <tal:block tal:repeat="item listmenu">
>             <li><a href="#" tal:replace="item/title">Title</a></li>
>             </tal:block>
> 
> 
> But if I try your example (I have adapted a little bit) this doesn't
> works :
> 
>                 <ul metal:define-macro="makemenu"
> tal:condition="listmenu">
>                     <li tal:repeat="item listmenu">
>                         <a href="#" tal:replace="item/title">Title</a>
>                         <tal:block metal:use-macro="makemenu"
> tal:define="listmenu item/submenu" />
>                     </li>
>                 </ul>
> 
> Any ideas ?

I have found the problem :
Just need to call the macro one time !
<tal:block metal:use-macro="makemenu" />

thanks


> Thanks a lots.
> 
> 
> Le vendredi 08 août 2008 à 22:46 +0200, Guillaume Lecanu a écrit :
> 
> > Le vendredi 08 août 2008 à 17:24 +0100, Kornel Lesiński a écrit : 
> > 
> > > On 08-08-2008 at 17:18:31 Guillaume Lecanu <[EMAIL PROTECTED]> wrote:
> > > 
> > > > But all the structure is stored in DB, so I don't know in advance if one
> > > > menu have 1, 2, or 10 childrens, and I don't know if a children is a
> > > > submenu.
> > > >
> > > > I know how to do that in PHP without PHPTAL, but how is it possible to
> > > > do that kind of XHTML code with PHPTAL ?
> > > 
> > > Of course. You can use macros called recursively:
> > > 
> > > <ul metal:define-macro="list" tal:condition="list">
> > >   <li tal:repeat="item list">...
> > >           <tal:block metal:use-macro="list" tal:define="list 
> > > item/sublist" />
> > >   </li>
> > > </ul>
> > 
> > Interresting, I'll try this.
> > 
> > 
> > Thanks Kornel & Iván
> > 
> > 
> > _______________________________________________
> > PHPTAL mailing list
> > PHPTAL@lists.motion-twin.com
> > http://lists.motion-twin.com/mailman/listinfo/phptal
> 
> _______________________________________________
> PHPTAL mailing list
> PHPTAL@lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to