[triangle-zpug] Getting DisplayList to show Values instead of keys
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-
> 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',
'Mary Ellen Jones',
'Medical Biomolecular Research Building',
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.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . .
Interrobang Digital Media
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the triangle-zpug