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.Click the sightings
document to edit it.
Click the View
tab to view it.
All the sightings should be marked as New.
Reload the page.
Now none of the sightings should be marked as New. This is because you've already seen them.
Click the sightingsFolder
folder to enter it.
Choose DTML Method
from the product add list.
Type Seattle
for the id. Since the title is optional and isn't
really needed in this case, leave the title field blank.
Click the Add and Edit
button.
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>
Click the Change
button.
Now you've created a new sighting. Let's see if it is marked as new by the sightings page.
Click the sightings
document in the lesson9
folder.
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.
Click the sightings
document to edit it.
The document sets a cookie with this code:
<dtml-call expr="RESPONSE.setCookie('lastVisited', ZopeTime())">
The document checks each sighting when displaying it to see if it is
newer than the lastVisited
cookie:
<dtml-if expr="bobobase_modification_time() > ZopeTime(lastVisited)">
Summary
You can use cookies to personalize a web page. Zope documents can dynamically control their presentation.
You can set cookies with the RESPONSE.setCookie
method.
The <dtml-if> tag allows you to test conditions.
The bobobase_modification_time
method returns the last
modification time of an object.
In the next lesson you'll learn how to create a mail feedback form.
Comments on this lesson? Email feedback.