[Zope] 'Cookie crumb trail' navigation
Andy McKay
andy@agmweb.ca
Fri, 22 Mar 2002 16:24:13 -0800
http://www.zopelabs.com/cookbook/990688377
----- Original Message -----
From: "Iago" <iago@iago.net>
To: <zope@zope.org>
Sent: Friday, March 22, 2002 3:19 PM
Subject: [Zope] 'Cookie crumb trail' navigation
> Howdy. I'll get right to it:
>
> Say I have a folder structure, a/b/c
>
> I'm in c. I want to establish some kind of method (my current attempts
> are a python script), stored in a, which will render the following:
>
> <a href="http://myserver.org/a/">A</a>:
> <a href="http://myserver.org/a/b/">B</a>:
> <b>C</b>:
>
> My current attempt only gets me:
>
> <a href="http://myserver.org/a/">A</a>:
> <b>C</b>:
>
> Here's the code for recursiveLinks:
>
> --- SNIP ---
>
> import string
>
> if list == None:
> list = []
>
> if len(list) > 0:
> list.append( '<a href="%s">%s</a>' %
> ( context.absolute_url(), context.title or context.id )
> )
> else:
> list.append( '<b>%s</b>' % context.title or context.id )
>
> if context is container:
> list.reverse()
> print string.join(list,' > ')
> return printed
> else:
> # this doesn't work: return context['..'].recursiveLinks(list=list)
> return container.recursiveLinks(list=list)
>
> --- SNIP ---
>
> Now, what I _really_ want is for 'context' to give me an object which
> is 'the context one level up from here', so I can recursively step up
> until i hit a folder I somehow designate as "top". I thought I was
> getting that with context and container, but as it turns out,
> container, where the above python script (recursiveLinks) lives, is
> not the container of context (the 'c' folder in this case) -- it's the
> container of the script (near as I can tell, since the result I'm
> getting is A: C and not A: B: C)
>
> How can I get 'next-folder-up' from this, in an object context so that
> I can grab the 'title' and other attributes off of the object, and
> recurse (as I thought I was doing above) by going to yet another
> 'next-folder-up'?
>
> Any help here's appreciated. I'm about 48 hours into learning zope. :)
>
> --
> Fred Hicks <iago@iago.net>
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>