[Zope] TAL conditional statement - newbie question

Gautam Saha gsaha at imsa.edu
Mon Nov 17 17:32:24 EST 2003


Thanks a lot Dieter, for your response.

I actually figure it out by looking at some codes and by using the 
template.getId()
as suggested by you.

Regards,

Gautam
--

Here is what I did if any one is interested:
===============  Code   in my news_slot.pt file ==============
<!-- Link to news Archive  from the News Slot -->

<p metal:define-macro="news_link">
    <span tal:condition="python:test(template.getId()!= 'news', 1,0)">
       <a href="news"
          tal:attributes="href string:$portal_url/news">
          <img tal:replace="structure here/linkTransparent.gif" />
        <span tal:omit-tag="" i18n:translate="news_archive">News 
Archive</span>

        </a>

    </span>

</p>
=============  End of Code  ==============

Dieter Maurer wrote:

>Gautam Saha wrote at 2003-11-17 08:54 -0600:
> > ...
> > Here are my questions:
> > 
> > 1. How to get the ID of an object (say "news" in this case so that
> > I can conditionally suppress the HREF, so that if I am in the
> > $portal_url/news page, the link will not display?
>
>If "o" is a Zope object "o.getId()" (as a python expression; it
>is "o/getId" as path expression) is
>its id.
>
>When you call a template, then inside it
>"template" refers to the template, i.e. "template.getId()" is
>the template's id.
>
> > 2. How can I use tal so that I don't have to hard code my portal URL
> > path (like href="/my.portal.edu/news")?
> > I want something like  href="$portal_url/news").
>
>If you call "portal_url", it returns the portal's URL.
>
>You can use this in a TALES "string" expression:
>
>    "string: ${container/portal_url}/news"
> > 3. Any online ref/example of how to use the Tal/python scripts
> > with ZOPE/CMF/Templates with small example will be helpful.
>
>Read the Zope Book (2.6 edition) and look into the "Examples"
>folder of "Products/PageTemplates".
>
>  
>




More information about the Zope mailing list