[Zope] presenting a list of stuff

ghaley@mail.venaca.com ghaley@mail.venaca.com
Mon, 16 Apr 2001 08:45:58 -0400 (EDT)


	hi sven,

Part I

	if you are iterating through a list of sequential items, but there
may be gaps in your list (due to a false value on your boolean), you can
build a python list, with something like:

<dtml-call "REQUEST.set('mylist',[])">  -- intializes an empty list.
<dtml-in "Item">  // whatever is holding your list.
  <dtml-let aa=sequence-item>
    <dtml-call "REQUEST.set('mylist',mylist+[aa])">
  </dtml-let>
</dtml-in>

	this will build your list, and it will leave any trailing ',' off
the end.  

Part II

	to get your alternating colors, as you loop through your list, you
can add a second call to the dtml-let (e.g., bb=sequence-index) which will
test for even/odd.  when even set a bgcolor var to one color, when odd set
it to the other.  with in the looping, you can also build up your display
table.

	most likely, someone will pipe in with a better way to do this;
but this is one approach.  

ciao!
greg.

Gregory Haley
DBA/Web Programmer
Venaca, LLC.

> hello,
> 
> i'd like to know whats the most elegant/practical/usefull way of displying a
> list of stuff (that might or might not be there).
> 
> i have a zclass with a couple of boolean properties and i'd like to display
> a list of *true* items this way :
> 
> ItemA,ItemB,ItemD,ItemE. (itemC is false)
> 
> i can do it pretty easily with a bunch of dtml-if (but it looks too ugly and
> my fingers hurt !) and i can't kill the "," before the last point.
> 
> p.s. i would prefer to do it in dtml since this has a lot more to do with
> presentation than logic and since the guys who will be coming after me will
> be even less python-enabled than i am ;-)
>