[Zope] creating link to parent container.

Sylvain Thénault Sylvain Thénault
Wed, 21 May 2003 14:22:06 +0200


On Wednesday 21 May à 14:15, Nicolas Évrard wrote:
> * John Kipling Lewis  [13:41 21/05/03 CEST]: 
> >On Wed, 21 May 2003, [iso-8859-1] Nicolas Évrard wrote:
> >
> >>is a link to the container of the page template. If this page template
> >>is acquired as in :
> >>
> >>http://.../site/animals/dog/waf/showPhoto with showPhoto a pt residing
> >>in animals, this link will point to http://.../site/animals.
> >>
> >>If you want to point to http://.../waf you should use
> >>'here/absolute_url'.
> >
> >I see the mistake I'm making now, we were looking at the index_html so my
> >URL looked like:
> >
> >http://.../site/animals/dog/waf/
> >
> >When I asked for "here/absolute_url" I got the same result.
> >
> >If I'm in "http://.../site/animals/dog/waf/", how do I return:
> >
> >http://.../site/animals/dog/
> 
> Well this is a quick hack (I didn't test it) :
> 
> In a pythonScript (parameter origin) :
> 
> url = origin.split('/')[:-1]
> return '/'.join(url)
> 
> and in your zpt :
> 
> <a href="#" tal:attributes="href python:upscript(here.absolute_url())">

you could also simply use the aq_parent attribute :

<a href="#" tal:attributes="href python:here.aq_parent.absolute_url()">

or 

<a href="#" tal:attributes="href here/aq_parent/absolute_url">

-- 
Sylvain Thénault                               LOGILAB, Paris (France).

http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org