[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Using Zope Page Templates

webmaster@zope.org webmaster@zope.org
Wed, 15 Jan 2003 15:02:52 -0500


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

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

    Another common use of conditions is to test a sequence to see if
    it is empty before looping over it. For example in the last
    section you saw how to draw a table by iterating over a collection
    of objects. Here's how to add a check to the page so that if the list
    of objects is empty no table is drawn::

      <table tal:condition="container/objectValues" 
             border="1" width="100%">
        <tr>
          <th>Number</th>
          <th>Id</th>
          <th>Meta-Type</th>
          <th>Title</th>
        </tr>
        <tr tal:repeat="item container/objectValues">
          <td tal:content="repeat/item/number">#</td>
          <td tal:content="item/getId">Id</td>
          <td tal:content="item/meta_type">Meta-Type</td>
          <td tal:content="item/title">Title</td>
        </tr>
      </table>

      % Anonymous User - Apr. 17, 2002 10:38 am:
       Sample does not completely work for me (in root "/" ).  
       I have to take out the last tal line (item/title) 
       otherwise I obtain authentification error! 

       Error Type: Unauthorized 
       Error Value: You are not allowed to access title in this context

      % Anonymous User - Apr. 27, 2002 9:16 pm:
       Works fine in all 'normal' folders

      % Anonymous User - May 23, 2002 1:47 pm:
       Same thing happens to me, but it happens in the earlier tal:repeat example, so I'd move this comment higher
       up.
       Also in Mozilla, hitting "cancel" actually logs me out so it's doubly inconvenient.

      % Anonymous User - May 30, 2002 3:39 pm:
       This is kind of a bad example of using a condition to not show anything.
       At the minimum it will show a table with one file (the file containing the code) and never not show the
       table.

      % Anonymous User - June 11, 2002 10:58 am:
       actually, I would like to see a way for the table to be created and exclude the page with the script. Ie.
       show everything in the containing folder OTHER than this page. (or how to EXCLUDE files in the report).
       Also, it would be nice to talk about how to add dynamic URLS to each file listing in the table.

      % Anonymous User - Jan. 15, 2003 3:02 pm:
       well, this one isn't smart at all... would be better to show a conditional 
       example similar to 
       if (something = "bla"){
         do something...
       }