Previous Chapter | Up | Next Section | Contents

A dtml- var Tag Example, the Default Document Source

When a Zope Document is created and no source is given, Zope supplies a default DTML source, as shown in figure 1.

Default Zope Document source

<dtml-var standard_html_header>
<H2><dtml-var title_or_id> <dtml-var document_title></H2>
<P>This is the <dtml-var document_id> Document in
the <dtml-var title_and_id> Folder.</P>
<dtml-var standard_html_footer>

In figure 1, several dtml- var tags are used. The first var tag inserts standard_html_header . Inserted in almost all Zope Documents, the standard_html_header is a Document which provides a standard way to begin HTML documents in a Zope installation. Thus, the inserted Document gives a Zope installation a common "look and feel". The standard_html_header document can be edited to customize a Zope installation and can be overridden in sub-folders to give different parts of a site varying appearances. The document standard_html_footer provides a similar function for the end of Zope documents. The var tags that insert standard_html_header and standard_html_footer illustrate the notion that DTML documents can be called from another DTML document.

The variables title_or_id and title_and_id are methods defined on most Zope objects. The method title_or_id returns the object's title if the title is not blank, otherwise the object's id is returned. The method title_and_id returns the title of an object followed by the id in parentheses if the title is not blank, otherwise the id is returned. In figure 1, the title_or_id and title_and_id methods are applied to the folder containing the document. The example illustrates the use of var tags to insert the results of method calls.

The variables document_id and document_title simply return the id and title of the document.

Previous Chapter | Up | Next Section | Contents