[Zope] Count of all objects within a container

Casey Duncan cduncan@kaivo.com
Tue, 03 Jul 2001 15:27:43 -0600


Tommy Johnson wrote:
> 
> Hey all,
> 
> I'm trying to get a count of all image objects within an images folder. The
> basic idea is to be able to use this count within an HTML table so I can
> format some rowspans. This bit of code will allow me to simply drop an image
> in, and the code will take care of generating my navigation bar.
> 
> Here's the problem. I want a count of images in the Images_naviagtion
> folder. By a manual count, I see 11. The code that I wrote is:
> 
> <dtml-with Images_navigation>
>     <dtml-in objectValues>
>         <dtml-var sequence-length>
>     </dtml-in>
> </dtml-with>
> 
> Now this gives me the correct answer of '11', but it gives it to me 11 times
> as well (most likely because if the dtml-in statement). How do I get it to
> just give me the correct answer ONCE?
> 
> Thanks in advance,
> Tommy
> 

You should be able to do that MUCH more efficiently with:

<dtml-var expr="_.len(Images_navigation.objectIds())">

hth,
-- 
| Casey Duncan
| Kaivo, Inc.
| cduncan@kaivo.com
`------------------>