[Zope] TAL conditional statement - newbie question

Gautam Saha gsaha at imsa.edu
Mon Nov 17 09:54:17 EST 2003


Hi ALL:

I am just starting to learn zope/plone and templates.
I have a portal that uses plone templets and skins.
My question is how I can HREF conditionally using TAL syntax.

I defined a macro in my plone template file (*.pt file)
like this:

<p metal:define-macro="news_link">
<-- Just link the News Archive -->
<a href="/my.portal.edu/news">News Archive  </a>
</p>

But, as this macro is called form the the right_slots
via the "properties Tab" for the CFM site object
(eg. here/news_slot/macros/news_link), this link will display in
all the pages in the right slot. But I don't want  this
link to be displayed when I am actually in that page itself 
(my.portal.edu/news).
Note: "news" is a CMF portal action called by
action  "string: $portal_url/news"

So the ideal code will be:
 If the current URL != $portal_url/news  then
    <a href="/my.portal.edu/news">News Archive  </a>
  else do nothing

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?

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

3. Any online ref/example of how to use the Tal/python scripts
with ZOPE/CMF/Templates with small example will be helpful.

Thanks,

Gautam




More information about the Zope mailing list