Lesson 9. Elvis, Up Close and Personal

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.

People who come to your site want a personal relationship with Elvis. You can provide this by tailoring your site to your viewer's needs and preferences. Let's add the ability to bring new Elvis sightings to the attention of site visitors. This way when a visitor comes to your site they'll immediately know which sightings are new since they last visited.
  1. Click the sightings document to edit it.
  2. Click the View tab to view it.

All the sightings should be marked as New.

  1. Reload the page.

Now none of the sightings should be marked as New. This is because you've already seen them.

  1. Click the sightingsFolder folder to enter it.
  2. Choose DTML Method from the "Select type to add..." list.
  3. Type Seattle for the id. Since the title is optional and isn't really needed in this case, leave the title field blank.
  4. Click the Add and Edit button.
  5. Change the contents of the method to:
    <p>6/1/2000 -- Seattle</p>
    <p>Elvis spotted spare changing on Broadway.
    He denied being the King.</p>
  6. Click the Save Changes button.

Now you've created a new sighting. Let's see if it is marked as new by the sightings page.

  1. Click the sightings document in the lesson9 folder.
  2. Click the View tab.

Sure enough our new sighting is marked New.

How does this work? It uses HTTP Cookies. When you visit the sightings page a cookie is set that records the current time. Then each time you return to the page sightings that are newer than the cookie will be marked as new.

Let's look at the DTML for the sightings page to see how this is done.

  1. Click the sightings document to view its contents.

The document sets a cookie with this code:

<dtml-call expr="RESPONSE.setCookie('lastVisited',

The document checks each sighting when displaying it to see if it is newer than the lastVisited cookie:

<dtml-if expr="bobobase_modification_time() >


You can use cookies to personalize a web page. Zope documents can dynamically control their presentation.

In the next lesson you'll learn how to create a mail feedback form.

Comments on this lesson? Email feedback.