getting image for a repeat item
Hello- I'm moving from dtml to ZPT on my site and have hit a snag. I have a MySQL staff database with generic info (firstname, lastname, etc.). Each staff member's photo is stored in the ZODB, in a photos folder at the root level. All photos take the form firstname_lastname, so in dtml I can say <img src="/photos/<dtml-var fistname>_<dtml-var lastname>"> I've worked out the code for getting the info out of the MySQL database: <div tal:repeat="adminstafflist container/get_tech_staff"> <span tal:replace="adminstafflist/name_first">first name</span></div> which is straightforward. How would I get the image from the photos folder to display, so that it will get the correct photo? I can use <img src="dummy.jpg" width="120" tal:attributes="src string:${root/photos/Kevin_Worth/absolute_url}"> to get my picture for everyone, but I need to know how to replace Kevin_Worth with the firstname_lastname of the repeat element. I suppose I could add a field to my database that would contain the location of the photo, but it seems that I shouldn't have to do it. Thanks for any pointers. Kevin
On Fri, 30 Jan 2004 14:03:18 -0500 Kevin Worth <kworth@engin.umich.edu> wrote:
Hello-
How would I get the image from the photos folder to display, so that it will get the correct photo?
I can use <img src="dummy.jpg" width="120" tal:attributes="src string:${root/photos/Kevin_Worth/absolute_url}"> to get my picture for everyone, but I need to know how to replace Kevin_Worth with the firstname_lastname of the repeat element.
Using python syntax: <img tal:attributes="src python:'%s/photos/%s_%s/absolute_url'%(root.absolute_url(), adminstafflist['first_name'], adminstafflist['last_name'])"> Or, <img tal:attributes="src python:path('root/photos/%s_%s/absolute_url'% (adminstafflist['first_name'], adminstafflist['last_name']))"> You may also be able to use the string: TALES option. Jim Penny
Thanks for any pointers.
Kevin
_______________________________________________ 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 (2)
-
Jim Penny -
Kevin Worth