First off...I just started playing with Zope today... This seems like it should be easy, but I've been searching google and the archives all day to no avail. I have an object ID and would like to display the object title as the content of a drop down menu. As it is now I can only display the ID: </select> <select name="querytype"> <span tal:define="ids root/Database/querytype/objectIds" tal:repeat="id ids" tal:omit-tag=""> <option tal:attributes="value id" tal:content="id">Item from sql method</option> </span> </select> What I want though is for the only the value to be the ID and the content to be the title. So something like this (which does not work): </select> <select name="querytype"> <span tal:define="ids root/Database/querytype/objectIds" tal:repeat="id ids" tal:omit-tag=""> <option tal:attributes="value id" tal:content="id/title">Item from sql method</option> </span> </select> I'm going to go get a good book on Zope and read it tonight. But if that doesn't help can anyone here help me out? Thanks Cliff Fogle Network Engineer Ofoto, Inc.
I am no expert but three ideas come immediately to mind. You need to get the object the id refers to before you can request its title. 1. I am pretty sure I have seen a method called something like an abbreviation for get object by id 2. use the portal_catalog 3. search the source code for title, and see what other things do with it or how they get it. ____________________________________________ Peter Millar -----Original Message----- From: zope-bounces@zope.org [mailto:zope-bounces@zope.org] On Behalf Of Cliff Fogle Sent: Wednesday, 15 December 2004 10:54 To: zope@zope.org Subject: [Zope] Getting title attribute given objectid First off...I just started playing with Zope today... This seems like it should be easy, but I've been searching google and the archives all day to no avail. I have an object ID and would like to display the object title as the content of a drop down menu. As it is now I can only display the ID: </select> <select name="querytype"> <span tal:define="ids root/Database/querytype/objectIds" tal:repeat="id ids" tal:omit-tag=""> <option tal:attributes="value id" tal:content="id">Item from sql method</option> </span> </select> What I want though is for the only the value to be the ID and the content to be the title. So something like this (which does not work): </select> <select name="querytype"> <span tal:define="ids root/Database/querytype/objectIds" tal:repeat="id ids" tal:omit-tag=""> <option tal:attributes="value id" tal:content="id/title">Item from sql method</option> </span> </select> I'm going to go get a good book on Zope and read it tonight. But if that doesn't help can anyone here help me out? Thanks Cliff Fogle Network Engineer Ofoto, Inc.
Cliff Fogle wrote:
First off...I just started playing with Zope today...
This seems like it should be easy, but I've been searching google and the archives all day to no avail. I have an object ID and would like to display the object title as the content of a drop down menu. As it is now I can only display the ID:
</select> <select name="querytype"> <span tal:define="ids root/Database/querytype/objectIds" tal:repeat="id ids" tal:omit-tag=""> <option tal:attributes="value id" *tal:content="id">*Item from sql method</option> </span> </select>
What I want though is for the only the value to be the ID and the content to be the title. So something like this (which does not work):
</select> <select name="querytype"> <span tal:define="ids root/Database/querytype/objectIds" tal:repeat="id ids" tal:omit-tag=""> <option tal:attributes="value id" *tal:content="id/title">*Item from sql method</option> </span> </select>
I'm going to go get a good book on Zope and read it tonight. But if that doesn't help can anyone here help me out? Thanks
Take a look at the docs for the 'objectIds' method: it returns a list of strings, being the ids of the contained objects. You cannot get attributes off a string. You must get the objects themselves. You would probably use 'objectValues' for this. --jcc
Read "The Zope Book" which is on the web -- http://www.plope.com/Books/2_7Edition On Tue, 14 Dec 2004, Cliff Fogle wrote:
First off...I just started playing with Zope today...
This seems like it should be easy, but I've been searching google and the archives all day to no avail. I have an object ID and would like to display the object title as the content of a drop down menu. As it is now I can only display the ID:
</select> <select name="querytype"> <span tal:define="ids root/Database/querytype/objectIds" tal:repeat="id ids" tal:omit-tag=""> <option tal:attributes="value id" tal:content="id">Item from sql method</option> </span> </select>
What I want though is for the only the value to be the ID and the content to be the title. So something like this (which does not work):
</select> <select name="querytype"> <span tal:define="ids root/Database/querytype/objectIds" tal:repeat="id ids" tal:omit-tag=""> <option tal:attributes="value id" tal:content="id/title">Item from sql method</option> </span> </select>
I'm going to go get a good book on Zope and read it tonight. But if that doesn't help can anyone here help me out? Thanks
Cliff Fogle Network Engineer Ofoto, Inc.
On 14.Dec 2004 - 16:53:52, Cliff Fogle wrote:
</select> <select name="querytype"> <span tal:define="ids root/Database/querytype/objectIds" tal:repeat="id ids" tal:omit-tag=""> <option tal:attributes="value id" tal:content="id">Item from sql method</option> </span> </select>
1. You don't have to define the "ids" variable, you could use root/Database/querytype/objectIds in repeat. 2. If you need the actual objects rather than just the id's use objectValues. so you should do something like: <span tal:repeat="obj root/Database/querytype/objectValues" tal:omit-tag=""> <option tal:attributes="value obj/id" tal:content="obj/title"></option> </span>
I'm going to go get a good book on Zope and read it tonight. But if that doesn't help can anyone here help me out? Thanks
The Zope-Book is very good for introduction. Andreas -- Just to have it is enough.
participants (5)
-
Andreas Pakulat -
Cliff Fogle -
Dennis Allison -
J. Cameron Cooper -
Peter Millar