Zope
  Home arrow Zope arrow Page 2 - DTML Basics (part 3)
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Developerworks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ZOPE

DTML Basics (part 3)
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    2002-07-02

    Table of Contents:
  • DTML Basics (part 3)
  • When In Rome...
  • A List In Time
  • An Easy Replacement
  • Bringing In The Database
  • Digging Deeper

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    DTML Basics (part 3) - When In Rome...
    (Page 2 of 6 )

    Not impressed yet? Let's alter the code a little to see what else you can do with sequences.

    <h3><dtml-var title_or_id></h3> <br> <dtml-in expr="'apple', 'banana', 'orange', 'apricot', 'grape'"> <sequence-length> <dtml-if sequence-start><i>Here's where it all starts</i><br></dtml-if> My name is <dtml-var sequence-item>, my sequence position is <dtml-var sequence-number>, and my index is <dtml-var sequence-index>.<br> <dtml-if sequence-end><i>And here's where it ends</i><br></dtml-if> </dtml-in>
    Now take a look at the output.

    Here's where it all starts My name is apple, my sequence position is 1, and my index is 0. My name is banana, my sequence position is 2, and my index is 1. My name is orange, my sequence position is 3, and my index is 2. My name is apricot, my sequence position is 4, and my index is 3. My name is grape, my sequence position is 5, and my index is 4. And here's where it ends
    This example uses a couple of new variables to add new functionality to the example. First, the "sequence-number" variable represents the position of the current item in the sequence, while the "sequence-index" variable provides an alternative zero-based indexing mechanism that serves the same purpose. And the "sequence-start" and "sequence-end" variables provide an easy way to find out if you're at the beginning or end of the sequence - the former is true when the current item is the first element of your sequence and the latter is true when the current element is the last element of the sequence.

    One more interesting variable (which I haven't demonstrated in the example above) is the "sequence-length" variable, which returns the number of items present in the sequence. There's also the "sequence-roman" variable, which can be used to display the sequence number using lower-case Roman numerals, the "sequence-Roman" for upper-case Roman numerals, and the "sequence-letter" and "sequence-Letter" variables for alphabetical indexing.

    More Zope Articles
    More By Harish Kamath, (c) Melonfire


     

       

    ZOPE ARTICLES

    - Creating Zope Products
    - Plone Content Types With Archetypes
    - Flat User Management in Zope
    - Creating Basic Zope Applications
    - Getting started with Zope for Linux and Sola...
    - ZPT Basics (part 4)
    - ZPT Basics (part 3)
    - ZPT Basics (part 2)
    - ZPT Basics (part 1)
    - Exception Handling In DTML
    - DTML Basics (part 4)
    - DTML Basics (part 3)
    - DTML Basics (part 2)
    - DTML Basics (part 1)
    - Using Zope With Apache

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway