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

Dissecting DTML - 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
Let's take a closer look at the DTML code which generated the screen on the previous page.


<dtml-var standard_html_header> <h2><dtml-var title_or_id></h2> <p> This is the <dtml-var id> Document. </p> <dtml-var standard_html_footer>
As you can see, this code block contains both HTML and DTML. When Zope processes this DTML Document instance, the DTML tags within it will be processed, and will be replaced with the resulting output. If you're familiar with PHP, JSP or ASP, this tag-based approach should already be familiar to you.

The first line of code

<dtml-var standard_html_header>
merely inserts the value of the DTML variable named "standard_html_header". This is one of the few predefined variables available in Zope, and, as the name suggests, it is used to display a common header for your site.

Next, the lines

<h2><dtml-var title_or_id></h2> <p>This is the <dtml-var id> Document.</p>
fetch and display either the document's title or its ID. If no title is available (as is the case here, since I never specified one when I created the object), Zope will make do with the ID.

Finally, the line

<dtml-var standard_html_footer>
inserts the value of another predefined Zope variable, "standard_html_footer". No prizes for guessing what this one's used for!

Obviously, you can just as easily omit all the DTML code and use a static HTML document - like this one:

<html> <head><basefont face="Arial"></head><body><h2>Can you say dee tee em el?</h2></body></html>
Zope will look for DTML tags within it and, finding none, will simply render the HTML as is.



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