[Zope] Dynamically Accessing Subfolders

Martijn Pieters mj@antraciet.nl
Wed, 20 Oct 1999 11:32:58 +0200


At 03:15 20/10/99 , James W. Howe wrote:
>At 06:14 PM 10/19/99 -0400, you wrote:
>>On Oct 19, 1999, James W. Howe wrote:
>>
>> > Is there a method that I can call for a folder which will give me it's
>> > subfolder names?  I'm assuming that if there was such a method, I 
>> could use
>> > a dtml-in tag to iterate over the results.  If there is such a method, 
>> what
>> > does it return and how could I use that information to send a message to
>> > each subfolder in turn?
>>
>>The method is called "objectValues". You can pass it a list of objects you
>>wish to enumerate within a container (an object manager).
>>
>>Here's a snippet of code that will do what you want:
>>
>>         <dtml-with A>
>>         <dtml-in "objectValues(['Folder'])">
>>           <dtml-with sequence-item>
>>            <dtml-var myName><BR>
>>           </dtml-with>
>>         </dtml-in>
>>         </dtml-in>

Note that within the in tag, you don't have to do dtml-with sequence-item, 
as this is implicit.


>This works like a charm.  Thanks.  Now here's a slight complication.  I 
>want to iterate over the folders in a particular order.  The order isn't 
>based on the name or id of the folder, rather it would probably be based 
>on a particular property value.  For example, I might have three sub 
>folders A, B, C but I might want to iterate over the collection in the 
>order B, A, C.  I could fudge things by naming the folders in a particular 
>sort order but I would rather not go that route if there is an alternative.

Just add a property to every Folder on which you sort:

   <dtml-with A>
     <dtml-in "objectValues(['Folder'])" sort=propertyname>
       <dtml-var myName><BR>
     </dtml-in>
   </dtml-in>

--
Martijn Pieters, Web Developer
| Antraciet http://www.antraciet.nl
| Tel: +31-35-7502100 Fax: +31-35-7502111
| mailto:mj@antraciet.nl http://www.antraciet.nl/~mj
| PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149
------------------------------------------