[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Dynamic Content with DTML

webmaster@zope.org webmaster@zope.org
Sat, 23 Nov 2002 18:51:24 -0500


A comment to the paragraph below was recently added via http://www.zope.org/Documentation/Books/ZopeBook/current/DTML.stx#3-160

---------------

      Here's an example of how to iterate over the contents of a
      folder. This DTML will loop over all the files in a folder and
      display a link to each one.  This example shows you how to
      display all the "File" objects in a folder, so in order to run
      this example you will need to upload some files into Zope as
      explained in the previous chapter::

        <dtml-var standard_html_header>
        <ul>
        <dtml-in expr="objectValues('File')">
          <li><a href="&dtml-absolute_url;"><dtml-var title_or_id></a></li>
        </dtml-in>
        </ul>
        <dtml-var standard_html_footer>

        % Anonymous User - May 30, 2002 10:52 pm:
         this code doesn't work, i've uploaded some files to the folder, and copied and pasted this code to a DTML
         document, but nothing come out!

        % Anonymous User - May 30, 2002 11:32 pm:
         Are you sure they were honest-to-god File objects and not DTML Methods or DTML Documents or something?

        % Anonymous User - May 31, 2002 12:00 am:
         of course!
         but it works after i've specified the folder name, the correct coding should be 
         <dtml-in expr="foldername.objectValues('File')">

        % Anonymous User - May 31, 2002 12:38 am:
         I've got another finding, the post-out coding is working under DTML method, but if using DTML document, have
         to do what i said, specified the folder name. :)

        % Anonymous User - June 12, 2002 6:49 am:
         Please be aware that 'honest-to-god' File objects seem to be a bit of an elitist group... when trying to
         iterate over folders containing pictures, I actually had to use <dtml-in expr="objectValues('Image')">.

        % mcdonc - June 15, 2002 11:44 am:
         Right. That's because File objects have a "meta_type" of File while Image objects have a meta_type of
         "Image". Try objectValues(('File', 'Image')) to get both.

        % Anonymous User - Oct. 16, 2002 7:53 am:
         How about if you are trying to iterate over DTML documents - i.e.: produce a navigation list? I've tried both
         <dtml-in expr="oral_microbiology.objectValues('Document')"> and
         <dtml-in expr="oral_microbiology.objectValues('Documents')">

        % Anonymous User - Nov. 23, 2002 6:51 pm:
         you can iterate over DTML documents using <dtml-in expr="objectValues('DTML Document')">