I wand generate a tree menu/sitemap. How can i make a recursive loop in a template???
In jinja i can use the tag "recurse": http://wsgiarea.pocoo.org/jinja/docs/loops.html#recursion Here a jinja example: ------------------------------------------------------------------------ context = {'sitemap': [{'href': u'/Index/', 'subitems': [{'href': u'/Index/PhpBBadmin/', 'title': u'phpBBadmin'}], 'title': u'index'}, {'href': u'/ExamplePages/', 'subitems': [{'href': u'/ExamplePages/TextileExample/', 'title': u'complete tinyTextile examples'}, {'href': u'/ExamplePages/Testpage/', 'title': u'a testpage ;)'}, {'href': u'/ExamplePages/SourceCode/', 'title': u'SourceCode'}, {'href': u'/ExamplePages/Contact/', 'title': u'contact'}, {'href': u'/ExamplePages/SiteMap/', 'title': u'SiteMap'}], 'title': u'example pages'}, {'href': u'/Test/', 'title': u'test'}]} template = """ <h1>Sitemap</h1> <ul> {% for item in sitemap %} <li> <a href="{{ item.href }}">{{ item.title|escapexml }}</a> {% if item.subitems %} <ul>{% recurse item.subitems %}</ul> {% endif %} </li> {% endfor %} </ul> """ ------------------------------------------------------------------------ recurse used the for loop again with the subitems. So i can easy create a recursion. How can i do this in django? -- Mfg. Jens Diemer ---- CMS in pure Python CGI: http://www.pylucid.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---