[Zope] dtml-if and dtml-else with ZPT
John Schinnerer
johnschinnerer@yahoo.com
Tue, 4 Jun 2002 13:56:39 -0700 (PDT)
Aloha,
> > I want to create a condition in ZPT. This is the condition in DTML:
> >
> > <dtml-in "PARENTS[0].objectValues('News')">
> > <dtml-if "_.sequence-item.id != PARENTS[0].id">
> > <a href="<dtml-var absolute_url"><dtml-var menu></a><br />
> > <dtml-else>
> > <dtml-var menu>
> > </dtml-if>
> >
>
> there is no *else* in TAL/TALES (ok, there is _.test() ),
> see
> http://www.zope.org/Members/peterbe/DTML2ZPT/#example2
...so 'else' or 'elif' is done with multiple condition statements, only
one of which will be true. A snippet from my menu macros (seems like
same thing you're trying to do - show link or not, depending on
context):
...
<p tal:condition="python:request.PARENTS[0].id!='designserv'">
<a href="/designserv/designserv.html">Design Services</a></p>
<p tal:condition="python:request.PARENTS[0].id=='designserv'">
<span class="boldrightnavtxt">Design Services</span>
...
If there's a slicker way to do this sort of thing in ZPT I'd be happy
to hear about it, but peterbe's example seems to show the same
method...?
cheers,
John S.
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com