How about a quick example to put all this in perspective? This next example allows you to replace the Zope management interface's folder listing with your own custom design, and also demonstrates how sequences can be used to do some fairly nifty things in Zope. And here's the output. ![]() Isn't that neat? Just some manipulation to the sequence used in the previous example, along with some predefined variables, and you're ready to rock and roll. First, I call the objectValues() method so that I have a sequence with the contents of the current folder. In this case, I've also added the "sort" attribute to the <dtml-in> tag - this allows me to specify the parameter by which sequence elements are to be sorted (the object ID). The special "sequence-even" variable provides an easy way to implement alternating colours for the list elements - it's set to true if the value of the "sequence-index" variable is even. So the first element has a grey background and the next a white one. If you want to switch it around, you can use the "sequence-odd" variable, which works in the reverse direction. The next section of the code is pretty straightforward- I've used various object properties to construct each row of the list: "icon" - the path and name of the icon that is displayed along the object in the Zope listing "id" - the object ID "get_size" - the size of the object in bytes "bobobase_modification_time" - the object's last modification time Remember the "sort" attribute of the "dtml-in" tag? I told you that you could easily alter this attribute to manipulate the sorting order of the sequence. Here's how: set the value of this attribute to "icon", "get_size" or "bobobase_modification_time" and check the output; you'll see that the items in the listing get re-sorted against the named parameter.
blog comments powered by Disqus |