[Zope] TAL conditional statement - newbie question

Dieter Maurer dieter at handshake.de
Mon Nov 17 14:19:19 EST 2003


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".

-- 
Dieter



More information about the Zope mailing list