[ZDP] BackTalk to Document The Zope Book (2.5 Edition)/Variables and Advanced DTML

nobody@nowhere.com nobody@nowhere.com
Wed, 11 Sep 2002 12:40:40 -0400


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

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

    Inside the *in* tag there are two main *if* tags. The first one
    tests special variable 'sequence-start'. This variable is only
    true on the first pass through the in block. So the contents of
    this if tag will only be executed once at the beginning of the
    loop. The second *if* tag tests for the special variable
    'sequence-end'. This variable is only true on the last pass
    through the *in* tag. So the second *if* block will only be
    executed once at the end.  The paragraph between the *if* tags is
    executed each time through the loop.

      % Anonymous User - Apr. 28, 2002 7:15 pm:
       This is a HORRIBLE example for usablity and should never be implemented.
       Instead, this should show how-to present <Previous and Next> links at the top and bottom of the batch. Then
       the example would need to show NOT to use <dtml-if previous-sequence> or <dtml-if next-sequence> because they
       dont work.
       Using <dtml-if previous-sequence-start-number>
       and <dtml-if next-sequence-start-number> is much more flexible and can be placed in any of the if-blocks at
       the top or bottom of the batch.
       And then it is still missing an explanantion on how to do batch navigation using the accepted standard of
       "Page" results. Page: 1 2 3 4 Next>

      % kaleissin - May 16, 2002 3:31 pm:
       One way is to use *two* dtml-ins... One for the header, one for the actual listing of the results. Which
       means everything is accessed/done twice. Then maybe you'd like to add the "<Previous 1 2 *3* 4 Next>" blurb
       *after* the results also, and you use a *third* dtml-in etc... nice excuse to buy a bigger server/faster cpu
       in the end, and lots of money going to your therapist ;)

      % Anonymous User - Sep. 11, 2002 12:40 pm:
       Here is an example how to do batch navigation using the 
       page 1 2 3 4 ...   Method
       I'm a Zope newbie, so it could possibly done more elegant.

       <dtml-call "REQUEST.set('save_url',_['absolute_url'])">     
       <dtml-in sqlMethod size=10 start=start>
         <dtml-if sequence-start>
           <p>Pages: 
           <dtml-call "REQUEST.set('actual_page',1)">
           <dtml-in previous-batches mapping>   
             <a href="<dtml-var save_url><dtml-var sequence-query>
                      start=<dtml-var "_['batch-start-index']+1">">
                      <dtml-var sequence-number></a>&nbsp;
             <dtml-call "REQUEST.set('actual_page',_['sequence-number']+1)">     
           </dtml-in>
           <b><dtml-var "_['actual_page']"></b>  
         </dtml-if>

         <dtml-if sequence-end>
           <dtml-in next-batches mapping>&nbsp;
              <a href="<dtml-var save_url><dtml-var sequence-query>
                     start=<dtml-var "_['batch-start-index']+1">">
                     <dtml-var "_['sequence-number']+_['actual_page']"></a>
            </dtml-in>
         </dtml-if>
        </dtml-in>