Lesson 6. Recent Elvis Sightings, cont.

Zope cannot find the tutorial examples. You should install the tutorial examples before continuing. Choose "Zope Tutorial" from the product add list in the Zope management screen to install the examples.

If you have already installed the tutorial, you can either follow along manually, or reinstall the tutorial examples. Note: make sure that you have cookies turned on in your browser.

So we've seen that the sightings page is built from objects in the sightingsFolder folder. How does it work?

  1. Click the sightings document to edit it.

  2. Change the contents of the document to::

    <dtml-var standard_html_header>
    <h2><dtml-var title></h2>
    
    <table border="1">
    <dtml-in expr="sightingsFolder.objectValues()">
    <tr><td>
      <dtml-var sequence-item>
    </td></tr>
    </dtml-in>
    </table>
    
    <dtml-var standard_html_footer>
  3. Click the Change button.

  4. Click the View tab.

Notice how each sighting now has a box drawn around it.

What's going on? The <dtml-in> tag iterates over a list of objects. The <dtml-var sequence-item> tag inserts the current object. The expr="sightingsFolder.objectValues()" part of the <dtml-in> tags tells it how to get a list of objects. It calls the objectValues method of the sightingsFolder folder. objectValues returns all the objects contained by a folder.

Summary

You can programmatically build web pages with groups of objects by looping over them and inserting them.

In the next lesson you'll learn about how to manage and display pictures.


Comments on this lesson? Email feedback.