A presumably simple question:
Is there an easy way to count the number of occurences of a certain meta type in a Catalog? E.g: I want a dtml snippet that outputs:
There are 123 DTML Documents in the Catalog.
I've browsed the howto's, but didn't find anything like this. Can anybody offer me some assistance?
To quote a mail by RD Murray from a gew days ago: How do I find the size of the results returned by the catalog? <dtml-let results=Catalog(....)> <dtml-var "_.len(results)"> <-- the results' length --> </dtml-let> Also at the zdp site: http://zdp.zope.org/projects/zsnippet/snippets/DTMLContent/CatalogResLength Rik
On Tue, 27 Jun 2000, Rik Hoekstra wrote:
To quote a mail by RD Murray from a gew days ago:
How do I find the size of the results returned by the catalog? <dtml-let results=Catalog(....)> <dtml-var "_.len(results)"> <-- the results' length --> </dtml-let>
Hmm. That wasn't my code. I'd suggest instead (untested, but I've used similar code in my own products): <dtml-in "Catalog(meta_type="Folder")" size=1> There are <dtml-var sequence-length> items of type Folder. </dtml-in> I'm not sure what the relative advantages of these two code snippets would be, but the latter does stick purely to dtml. --RDM
OK.. how about one more little special case.... There are <dtml-in "Catalog(meta_type="Folder")" size=1> <dtml-var sequence-length> <dtml-else> 0 </dtml-in> items of type Folder. untested of course. ;-) -steve RDM wrote: ---------------------------------------------------------------------- On Tue, 27 Jun 2000, Rik Hoekstra wrote:
To quote a mail by RD Murray from a gew days ago:
How do I find the size of the results returned by the catalog? <dtml-let results=Catalog(....)> <dtml-var "_.len(results)"> <-- the results' length --> </dtml-let>
Hmm. That wasn't my code. I'd suggest instead (untested, but I've used similar code in my own products): <dtml-in "Catalog(meta_type="Folder")" size=1> There are <dtml-var sequence-length> items of type Folder. </dtml-in> I'm not sure what the relative advantages of these two code snippets would be, but the latter does stick purely to dtml. --RDM _______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Tue, 27 Jun 2000, Steve Spicklemire wrote:
OK.. how about one more little special case....
There are <dtml-in "Catalog(meta_type="Folder")" size=1> <dtml-var sequence-length> <dtml-else> 0 </dtml-in> items of type Folder.
Um...yep. Just actually looked at my code, and I do indeed have that special case in my working code <apologetic grin>. That probably makes the set/len code the less complex of the two. --RDM
participants (3)
-
R. David Murray -
Rik Hoekstra -
Steve Spicklemire