Easy way to display a random image in ZPT
Hi *, What's the easiest way to do the following DTML in ZPT? <img src="images/<dtml-var expr="_.whrandom.choice(imgages.objectIds())">" /> Regards, Michael
Michael Fox wrote:
Hi *,
What's the easiest way to do the following DTML in ZPT?
<img src="images/<dtml-var expr="_.whrandom.choice(imgages.objectIds())">" />
Easy: Save this DTML method as random_image: ----8<------8<------8<------8<------8<------8<-- <img src="images/<dtml-var expr="_.whrandom.choice(imgages.objectIds())">" /> ----8<------8<------8<------8<------8<------8<-- and call this dtml method from your ZPT Regards, -- Jaroslav Luke -- Tento e-mail nemu*e obsahovat VIRY jeliko nepocházi z virózního systému M$ Windows!
Hi Try this: <img tal:define="rid python:whrandom.choice(here.images.objectIds())" tal:attributes="src string:/images/${rid}"> This code works for a folder images in the ROOT and page template in the ROOT. You can adapt it of course. Dragos
Michael Fox wrote:
Hi *,
What's the easiest way to do the following DTML in ZPT?
<img src="images/<dtml-var expr="_.whrandom.choice(imgages.objectIds())">" />
Easy:
Save this DTML method as random_image: ----8<------8<------8<------8<------8<------8<-- <img src="images/<dtml-var expr="_.whrandom.choice(imgages.objectIds())">" /> ----8<------8<------8<------8<------8<------8<--
and call this dtml method from your ZPT
Regards,
--
Jaroslav Lukes
-- Tento e-mail nemu*ze obsahovat VIRY jelikoz nepocházi z virózního systému M$ Windows!
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Dragos Chirila -
Jaroslav Lukesh -
Michael Fox