Home arrow Zope arrow Page 5 - DTML Basics (part 4)

Climbing A Tree - Zope

In this concluding article, dip your toes in the waters of more advanced DTML programming, with explanations of the , and tags.

  1. DTML Basics (part 4)
  2. With Or Without You
  3. A Polite Request
  4. Let Me In
  5. Climbing A Tree
  6. The Real Thing
  7. Call Of The Wild
  8. The Writing On The Wall
  9. Endzone
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 5
July 17, 2002

print this article


One of the most striking features of the Zope Management Interface is the navigation menu that appears on the left side. And the cool thing is, Zope comes with a built-in construct that allows you to replicate and use this tree structure for your own purposes. It's called the <dtml-tree> tag - and here's what it looks like:

<dtml-tree> <dtml-var getId> </dtml-tree>
This is a very simple implementation of the <dtml-tree> tag...as you can see from the output below:

Here, the <dtml-tree> tag dynamically searches for the objects in the current folder and lists them by ID. It is obvious that, by default, it lists only the folders in the current location.

Now, let me make the example more interesting:

<dtml-tree branches_expr="objectValues()" sort=id> <dtml-var getId> </dtml-tree>
Here's the output:

I now have a listing of all the objects in the current folder along with a neat little icon that allows downward traversal. Give it a shot and you'll see that you can now see all the objects under the current folder.

<dtml-tree branches_expr="objectValues()" sort="id">
The additional "branch_expr" attribute of the <dtml-tree> tag is used to specify the expression that will be evaluated by Zope to display the listing of the objects in the tree. The "sort" attribute tells Zope to sort the list by ID.

Want to play around with the code shown above? Just add the "reverse" attribute:

<dtml-tree branches_expr="objectValues()" sort="id" reverse>

Here's a brief list of the most useful <dtml-tree> attributes - try them at your leisure:

"header" - this allows you to specify a DTML document that will be displayed as a header for each expanded node.

"footer" - this is similar to the "header" attribute explained above, as it allows you to specify the footer for each expanded note.

"nowrap" - set this to true if you want to truncate the nodes if there isn't enough space to expand them.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


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