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

Practical Magic - Zope

Contrary to what you might think, DTML isn't the only programming language available to you in Zope. Take a look at Zope Page Templates (ZPT), a template-based alternative that makes it easier for designers and developers to collaborate on Zope application development.

TABLE OF CONTENTS:
  1. ZPT Basics (part 1)
  2. The Power Of Three
  3. Practical Magic
  4. Anatomy Lesson
  5. Putting It All In Context
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 23
September 18, 2002

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
Let's take a look at a more concrete example of how TAL works. Start up Zope and log in to the management interface with the user name and password that was created when you installed Zope.

As you should know by now, this is the tool that you will be using to build your Web applications. You can use it to create documents, folders, and your own Zope products. And the first step in this process is to create a folder to store all the objects we're going to be creating.

Create a Folder by selecting it from the drop-down menu that appears at the top of the page, and name it "ZPT Basics".

The next step is to navigate to the folder that you just created and add a Page Template to it, using the process outlined above.



Give this template an ID of "MyFirstTemplate", and a title of "Hello ZPT!".

As you may have guessed by now, the object ID that you assign at each stage is fairly important - it provides a unique identifier for the object within Zope, which can be used to access and manipulate it from your scripts.

A default page template will be created in the "ZPT Basics" folder. Replace the code within it with the following:

<html> <head> <title tal:content="template/title">The title</title> </head> <body> <h2>Welcome to <span tal:replace="here/title_or_id">content title or id</span></h2> This is a Page Template with ID <em tal:content="template/id">template id</em> and title <em tal:content="template/title">template title</em>. </body> </html>
Here's the output of this template (you can see this via the "Test" option in the Zope management interface),



and here's the corresponding HTML code generated by Zope.

<html> <head> <title>Hello ZPT!</title> </head> <body> <h2>Welcome to ZPT Basics</h2> This is a Page Template with ID <em>MyFirstTemplate</em> and title <em>Hello ZPT!</em>. </body> </html>


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