Home arrow Zope arrow Page 6 - DTML Basics (part 1)

Green Cheese And Pink Frogs - Zope

Always wanted to learn DTML, but didn't know where to start? Today's your lucky day.

TABLE OF CONTENTS:
  1. DTML Basics (part 1)
  2. Upper Management
  3. Dissecting DTML
  4. Of Methods And Madness
  5. Introducing Yourself
  6. Green Cheese And Pink Frogs
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 9
May 21, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
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
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

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

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: