[Zope] dtml-in help

hans hans@beehive.de
Fri, 01 Mar 2002 16:19:55 +0000


Todd Loomis wrote:

> Hi All:
>
> I want to put a set <dtml-in> tag based on a select variable as such:
>
> <dtml-if "select=='All'">
> <dtml-in get_all_users>
> <dtml-else>
> <dtml-in get_select_users>
> </dtml-if>
>
> but I keep getting an error. Can I do this?

1) dtml-tags *MUST* nest proper
2) <dtml-in "_.test(select=='All', get_all_users(), get_select_users())">

is a good idea
3) you might also bind methods to REQUEST-variables like so:
<dtml-call "REQUEST.set( 'filter_users', _.test(select=='All',
get_all_users, get_select_users) )">
note missing parens
and
<dtml-in filter_users>
</dtml-in filter_users>
better though:
<dtml-in "filter_users()">
</dtml-in filter_users>
note the discussion of name- and expr- attributes in
http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html
4) also possible: bind result to a REQUEST-var
<dtml-if "select=='All'"><dtml-call "REQUEST.set( 'filterd_users',
get_all_users() )">
<dtml-else><dtml-call "REQUEST.set( 'filterd_users', get_select_users()
)"></dtml-if>
<dtml-in filterd_users>
...
</dtml-in filterd_users>
--------------------------------------------------------------
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