[Zope] "Picture of the day" product
Eric Walstad
eric@walstads.net
Wed, 17 Jan 2001 10:59:06 -0800
// What I'm not sure about is how to have Zope automatically
// display the photo
// for a day, then archive it. Would a boolean property of the
// ZClass work? Is
// it possible to have Zope set the property of a ZClass instance
// at certain
// time? Any thoughts on how this would be designed?
Hi Tim,
Here's some code I use with a simple NewsItem ZClass that only displays
objects that have not yet "Expired". With a little modification, it could
be used to test a "DisplayDate" value and if it matches the current date,
the photo would be displayed. That way you could load a bunch of photos
into your site at once and give them specific display dates. If more than
one had the same date, they would both be shown.
"Expires" is a property of my NewsItem ZClass that is of type "date".
"Expires+1" just adds a day to the expiration date so that my news items are
displayed up to, and including, their expiration date. The NewsItem ZClass
has a meta type of "News Item," which is used in the "in" statement. "view"
is a method of the ZClass that simply formats the NewsItem for displaying in
the browser.
<dtml-with News>
<dtml-in expr="objectValues('News Item')" sort=id reverse>
<dtml-if "ZopeTime().lessThanEqualTo((Expires+1))"><dtml-var
view><br></dtml-if>
</dtml-in>
</dtml-with>
Hope it helps...
Eric.