I wanted to randomly pick a an image from an images folder and insert it into my page. So I created a python script the return a random selection from the images folder. Then, in my zpt I did <span tal:define="global slot1 container/getimageR1" > <!-- slot one item --> </span> Later in in the <img> tag I wanted to to do <img tal:attributes="src slot1" > however I found that slot1 was not giving me the full path to the images folder. So I went back and did this: <span tal:define="slot1 container/getimageR1" > <!-- slot one item --> <span tal:define="global s1 python:'random1/'+slot1.getId()"></span> </span> in order to get the object to have the full url. It just seems there should be a better way. Anyone have a suggestion? -- David Bear phone: 602-496-0424 fax: 602-496-0955 College of Public Programs/ASU University Center Rm 622 411 N Central Phoenix, AZ 85007-0685 "Beware the IP portfolio, everyone will be suspect of trespassing"
+-------[ David Bear ]---------------------- | I wanted to randomly pick a an image from an images folder and insert | it into my page. So I created a python script the return a random | selection from the images folder. | | Then, in my zpt I did | | <span tal:define="global slot1 container/getimageR1" > | <!-- slot one item --> | </span> | | Later in in the <img> tag I wanted to to do | | <img tal:attributes="src slot1" > | | however I found that slot1 was not giving me the full path to the | images folder. So I went back and did this: [snip] | It just seems there should be a better way. Anyone have a suggestion? Get your getimageR1 script to return randomImage.absolute_url(), instead of the image itself? -- Andrew Milton akm@theinternet.com.au
On 20.09.2006, at 02:24, David Bear wrote:
I wanted to randomly pick a an image from an images folder and insert it into my page. So I created a python script the return a random selection from the images folder.
Then, in my zpt I did
<span tal:define="global slot1 container/getimageR1" > <!-- slot one item --> </span>
Later in in the <img> tag I wanted to to do
<img tal:attributes="src slot1" >
however I found that slot1 was not giving me the full path to the images folder. So I went back and did this:
<span tal:define="slot1 container/getimageR1" > <!-- slot one item --> <span tal:define="global s1 python:'random1/'+slot1.getId()"></span> </span>
tal:attributes="src slot1/absolute_url"
in order to get the object to have the full url.
It just seems there should be a better way. Anyone have a suggestion?
-- David Bear phone: 602-496-0424 fax: 602-496-0955 College of Public Programs/ASU University Center Rm 622 411 N Central Phoenix, AZ 85007-0685 "Beware the IP portfolio, everyone will be suspect of trespassing" _______________________________________________ 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)
-
Andrew Milton -
Bernd Dorn -
David Bear