Zope
  Home arrow Zope arrow Page 4 - 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 Rational Software Development Conference
 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

    PCmover - $15 Off with Coupon Code CJPH7Q

    DTML Basics (part 3) - An Easy Replacement
    (Page 4 of 6 )

    How about a quick example to put all this in perspective? This next example allows you to replace the Zope management interface's folder listing with your own custom design, and also demonstrates how sequences can be used to do some fairly nifty things in Zope.

    <table cellpadding="5" cellspacing="0" border="0"> <tr bgcolor="#CFCFCF"> <td><b>Type</b></td> <td><b>Name</b></td> <td><b>Size</b></td> <td><b>Last Modified</b></td> </tr> <dtml-in expr="objectValues()" sort="id" > <dtml-if sequence-even> <tr bgcolor="#DCDCDC"> <dtml-else> <tr> </dtml-if> <td><img src="<dtml-var sequence-var-icon>" border="0"></td> <td><a href="&dtml-absolute_url;"><dtml-var sequence-var-id></td> <td><dtml-var sequence-var-get_size> bytes</td> <td><dtml-var sequence-var-bobobase_modification_time></td> </tr> </dtml-in> </table>
    And here's the output.



    Isn't that neat? Just some manipulation to the sequence used in the previous example, along with some predefined variables, and you're ready to rock and roll.

    <dtml-in expr="objectValues()" sort="id" > <dtml-if sequence-even> <tr bgcolor="#DCDCDC"> <dtml-else> <tr> </dtml-if>
    First, I call the objectValues() method so that I have a sequence with the contents of the current folder. In this case, I've also added the "sort" attribute to the <dtml-in> tag - this allows me to specify the parameter by which sequence elements are to be sorted (the object ID).

    The special "sequence-even" variable provides an easy way to implement alternating colours for the list elements - it's set to true if the value of the "sequence-index" variable is even. So the first element has a grey background and the next a white one. If you want to switch it around, you can use the "sequence-odd" variable, which works in the reverse direction.

    <td><img src="<dtml-var sequence-var-icon>" border="0"></td> <td><a href="&dtml-absolute_url;"><dtml-var sequence-var-id></td> <td><dtml-var sequence-var-get_size> bytes</td> <td><dtml-var sequence-var-bobobase_modification_time></td>
    The next section of the code is pretty straightforward- I've used various object properties to construct each row of the list:

    "icon" - the path and name of the icon that is displayed along the object in the Zope listing

    "id" - the object ID

    "get_size" - the size of the object in bytes

    "bobobase_modification_time" - the object's last modification time

    Remember the "sort" attribute of the "dtml-in" tag? I told you that you could easily alter this attribute to manipulate the sorting order of the sequence. Here's how: set the value of this attribute to "icon", "get_size" or "bobobase_modification_time" and check the output; you'll see that the items in the listing get re-sorted against the named parameter.

    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 3 hosted by Hostway