dtml-if and dtml-else with ZPT
Hi all, 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> Can someone translate this in tal-code? Thanks! Greetz Nico
Nico de Boer wrote:
Hi all,
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>
Can someone translate this in tal-code?
there is no *else* in TAL/TALES (ok, there is _.test() ), see http://www.zope.org/Members/peterbe/DTML2ZPT/#example2 -- ------------------------------------------------------------- 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
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
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
John Schinnerer <johnschinnerer@yahoo.com> wrote:
... <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...?
I use: <tal:block define="cond python:request.PARENTS[0].id!='designserv'"> <a tal:condition="cond" href="/designserv/designserv.html">Design Services</a> <span tal:condition="not:cond" class="boldrightnavtxt">Design Services</span> </tal:block> Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com
participants (4)
-
Florent Guillaume -
hans -
John Schinnerer -
Nico de Boer