[Zope-dev] Re: [Zope] Looping through a folder's contents...
jiva@devware.com
jiva@devware.com
Mon, 21 Aug 2000 01:38:19 -0700
What would the "Recurse_Subfolder" method do?
On Mon, Aug 21, 2000 at 04:12:05PM +1000, Andrew Kenneth Milton wrote:
> +-------[ jiva@devware.com ]----------------------
> | I would like to loop through the contents of a folder, and the
> | contents of the subfolders of that folder. I know I can do this to a
> | singular level by doing something like:
> |
> | <dtml-in "subfolder.objectValues('Folder')">
> | <dtml-var title>
> | </dtml-in>
> |
> | Should give me a list of the titles of all the subfolders of the
> | folder called "subfolder". So, once I get there, how do I loop
> | through the subobjects of each of those folders?
> |
> | In other words, I have a subfolder inside of the folder called
> | "subfolder" and I want to see the contents of that folder. How do I
> | do it?
>
> I'll give you the general case for 'all' folders:-
>
> Make a Method... Recurse_SubFolder.
>
> <dtml-in "root.objectValues('Folder')">
> <dtml-in "_.range(depth)"> </dtml-in><dtml-var title>
> <dtml-var "Recurse_SubFolder(root=this(),depth=depth+1)">
> </dtml-in>
>
>
> <dtml-var "Recurse_SubFolder(root=subfolder, depth=0)">
>
>
> You can obviously expand this to also take a 'type' for objectValues,
> and pass the namespace etc.
>
--
A homeowner's reach should exceed his grasp, or what's a weekend for?