Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Message from discussion Generate a tree List...
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Joseph Heck  
View profile  
 More options Feb 28 2007, 4:12 pm
From: "Joseph Heck" <joseph.h...@gmail.com>
Date: Wed, 28 Feb 2007 13:12:50 -0800
Local: Wed, Feb 28 2007 4:12 pm
Subject: Re: Generate a tree List...

The templates don't support that kind of functionality directly. You'll
probably want to create your own template tag that will do for you - you can
recurse to your heart's content in Python.

Check out the docs at
http://www.djangoproject.com/documentation/templates_python/ for a good
overview. Making one is really pretty straightfoward.

On 2/27/07, Jens Diemer <python_gm...@jensdiemer.de> wrote:

> 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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.