Zope
  Home arrow Zope arrow Page 6 - DTML Basics (part 1)
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 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 1)
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 9
    2002-05-21


    Table of Contents:
  • DTML Basics (part 1)
  • Upper Management
  • Dissecting DTML
  • Of Methods And Madness
  • Introducing Yourself
  • Green Cheese And Pink Frogs

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    DTML Basics (part 1) - Green Cheese And Pink Frogs
    ( Page 6 of 6 )

    You can also format variable values with DTML's numerous formatting attributes. Consider the following DTML Document, which contains a simple HTML form.

    <html> <head></head> <body> <form action="FormatForm" method="post"> <input type="hidden" name="someString" value="the cow jumped over a hunk of green cheese, and a pink frog turned into a hummingbird"> <input type="submit" name="submit" value="Hit Me!"> </form> </body> </html>
    Once this form is submitted (to another DTML Document instance named "FormatForm"), the form variables and their values become available within the Zope namespace. Here's what FormatForm looks like:

    <html> <head></head> <body> Look how big I am: <br> <dtml-var someString upper>. <p> Don't cut me off when I'm talking: <br> <dtml-var someString size="14" etc="..."> <p> </body> </html>
    It isn't very hard to guess what this script does:



    The <dtml-var> tag comes with a bunch of attributes designed to format the data within it. Here are the important ones:

    capitalize - uppercases the first character of the variable;

    upper - uppercases the entire variable;

    lower - lowercases the variable;

    size - restricts the number of characters of the variable that are displayed;

    etc - displays a string following the variable.

    You can also format the display of the DTML variables using "structured text", which, according to http://www.Zope.org/Members/millejoh/structuredText, is "...text that uses indentation and simple symbology to indicate the structure of a document". Or, in other words, structured text is a set of predefined rules that Zope understands and can use to automatically format your document for you.

    In order to see how this works, add the following line of code to the form above,

    <input type="hidden" name="someOtherString" value='"Liked this? Send me mail", mailto:neo@theone.com'>

    and the following line to the form processor:

    <dtml-var someOtherString fmt="structured-text">

    Here's what the revised output looks like:



    As you can see, Zope uses its structured text rulesets to automatically hyperlink the text string to the email address specified.

    I'm not going to get into the details of structured text here - there are some great references out there, with my personal favourite being the one at http://www.zope.org/Members/redsea/Wiki/StructuredTextRules. Play with it, and you'll get the hang of it soon enough.

    In the meanwhile, I'm out of here. But fear not - your journey into the wild and wacky world that is DTML has just begun, and I will be back with more next week, complete with maps and lollipops. See you then!

    Note: All examples in this article have been tested on Linux/i586 with Zope 2.5.0. Examples are illustrative only, and are not meant for a production environment. Melonfire provides no warranties or support for the source code described in this article. YMMV!

     
     
    >>> 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





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT