[Zope] dtml-if and dtml-else with ZPT

hans hans@beehive.de
Wed, 05 Jun 2002 10:28:14 +0100


John Schinnerer wrote:

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

not much slicker, from the top of my head
(i really never *used* ZPTs so far)

--
-------------------------------------------------------------
Who's got only a hammer sees the world as a nail
hans augustin  (software developer)           hans@beehive.de
beehive elektronische medien GmbH       http://www.beehive.de
phone: +49 30 847-82 0                  fax: +49 30 847-82 299