Le 23/03/2011 15:53, chafik a écrit :
Hi,

I'm creating a project based on Symfony2 and Twig and I'm wondering
how to realize recursivity in Twig.
I've searched in the documentation but haven't found anything :)

I have an XML template and I want to output something like this :

<pages>
      <page>
           <title>Page 1</title>
           <content>My content</content>
           <pages>
                <page>
                     <title>Subpage 1</title>
                     <content>My content 2</content>
                       ............etc.......
                <page>
           </pages>
      </page>
</pages>

I acces to subpages with page.children.

Do one of you have an idea on how to do it ?

Thank you ;)

The best solution IMO is to use {% include %} to include a template responsible of rendering a <page> item with the good variables. You can do this recursively.

--
Christophe | Stof

--
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to