[Zope] Create level up link with ZPT (TAL)

Nico de Boer nico@nfg.nl
13 Jun 2002 11:17:11 +0200


Hi,

I want to create a level up link in my ZPT. I've done this in Python
and it looks like this:

    def news_levelup(self):
        """return a hyperlink to the parentobject if there is one"""
        s = ''
        if self.REQUEST['PARENTS'][1].meta_type == 'News':
            if len(self.REQUEST['PARENTS'][1].level_up_txt) > 2:
                s = s + '<a class="gnawlink" href="%s">%s</a><br />' \
                    % (self.REQUEST['PARENTS'][1].absolute_url(),
                       self.REQUEST['PARENTS'][1].level_up_txt
                       )
            else:
                s = s + '<a class="gnawlink" href="%s"><img src="%s" border="0" \
                alt="level up"></a><br />' \
                    % (self.REQUEST['PARENTS'][1].absolute_url(),
                       self.REQUEST['PARENTS'][1].upfolder
                       )
            return s
        else:
            return ''

I've tried the following, but that doesn't work:

    <span
        tal:condition="python:here.has_parents()">
    <a class="gnawlink" href=""
        tal:attributes="href container/absolute_url"
        tal:content="container/level_up_txt">
    <img src="placeholder.gif" width="16" height="16" border="0" alt="item"
        tal:attributes="src here/upfolder; alt here/meta_type" /></a>
    </span>

The python method has_parents checks if the current object has a
parent of the same metatype.

Can somebody help me out?

Greetz Nico