[triangle-zpug] Getting DisplayList to show Values instead of keys
Jim Allman
jim at ibang.com
Wed Jun 21 06:37:04 CEST 2006
Rob, I know this is a very old thread, but I'm wondering if you found
an answer to this question:
On Mar 23, 2006, at 11:47 AM, Rob Lineberger wrote:
> Brief question, followed by a winding (but fruitless) road of self-
> discovery...
>
> If you specify a DisplayList as the Vocabulary for an AT Field
> called building:
>
> BUILDING = DisplayList((
> ('bank-of-america', 'Bank of America'),
> ('lineberger', 'Lineberger'),
> ('mary-ellen-jones', 'Mary Ellen Jones'),
> ('macnider', 'Macnider'),
> ('mbrb', 'Medical Biomolecular Research Building'),
> ('other', 'Other'),
> ))
>
> ...And you use the default accessor getBuilding in your page
> template, it will display the id ('mbrb' instead of 'Medical
> Biomolecular Research Building'). How do you get the getBuilding
> accessor to show the "value" instead of the "key"?
I've run into the same problem, and after a couple of hours digging
through Archetypes source code, just decided to punt with a simple
list of values, like so:
BUILDING = [
'Bank of America',
'Lineberger',
'Mary Ellen Jones',
'Macnider'
'Medical Biomolecular Research Building',
'Other'
]
This is less common in examples, but works just fine.
Of course, with this method the same string is used for storage and
display of a value. Now my view templates show a friendly value, and
so far I can't see a down-side to storing these strings as values.
Granted, it's lousy for i18n, and it'll be a pain if the client wants
to tweak the display names. (I suppose we'd need to revise all
existing objects to replace old with new string values.)
Anyway, I hope this helps someone out there.
=jimA=
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
Jim Allman
Interrobang Digital Media
http://www.ibang.com/
(919) 649-5760
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://starship.python.net/pipermail/triangle-zpug/attachments/20060621/47afe59e/attachment.htm
More information about the triangle-zpug
mailing list