[Zope] Fetching the title of object whose id is passed in query string

Ben Gustafson cbg3@earthlink.net
Sat, 01 Dec 2001 20:50:29 -0500


Thanks, Danny. You not only showed me a much more elegant way to display
the image object's title, but I learned some new syntax as well!

--Ben

> Subject: Re: [Zope] Fetching the title of object whose id is passed in query string
> Date: Thu, 29 Nov 2001 16:44:50 +1300
> > I'm working on my first Zope project, an on-line photo galley, now
> > located at http://localhost:8080/gallery/ . The image objects are stored
> > in a subfolder called "imgs". The page at the above URL has a nav bar
> > with links that have the id of the image object to display in a query
> > string, like so: http://localhost:8080/gallery/?imgID=doorway. What I
> > want to do is display below the image the title of the image object
> > whose id is passed in the query string, sort of like a caption. For some
> > reason, though, I can't figure out how to ask for the image object's
> > title directly. What I'm doing now (and which works, but is ugly), is
> > this:
> >
> > <dtml-if imgID>
> >   <dtml-in expr="imgs.objectValues()">
> >     <dtml-if "imgID==_['id']">
> >       <IMG SRC="imgs/<dtml-var imgID>" width=<dtml-var width>
> > height=<dtml-var height>>
> >       <P align="center"><dtml-var title></P>
> >     </dtml-if>
> >   </dtml-in>
> > </dtml-if>
> >
> > How do I just do <dtml-var expr="imgs.title_or_id(imgID)"> 
> > (or something like that) and make it work?
> 
> <dtml-var "imgs[imgID].title_or_id()">
> 
> 
> hth,
> Danny