Hi, I'm wondering how I can do this little trick (sp_info is a globaly devide var, it's a dictionary obj): <option tal:repeat="group groups/existing/high" tal:content="group" tal:attributes="onmouseover string:doTooltip(event, '${sp_info/${group}/common_name}')" onmouseout="hideTip()"> </option> So based on my the value of 'group' from my repeat, I want to use the value to look up another value in a different dictionary. It works if I do this: (event, '${sp_info/whatever/common_name}') but does not like me using the embedded ${group}. Thanks, Jason. -- ........................................ .... Jason C. Leach .... PGP Key: 0x62DDDF75 .... Keyserver: gpg.mit.edu
Jason C. Leach wrote:
I'm wondering how I can do this little trick (sp_info is a globaly devide var, it's a dictionary obj):
<option tal:repeat="group groups/existing/high" tal:content="group" tal:attributes="onmouseover string:doTooltip(event, '${sp_info/${group}/common_name}')" onmouseout="hideTip()"> </option>
So based on my the value of 'group' from my repeat, I want to use the value to look up another value in a different dictionary. It works if I do this: (event, '${sp_info/whatever/common_name}') but does not like me using the embedded ${group}.
The ${var} syntax is only for inserting a value in a string expression. Path expressions only take known names. If you want to look up a value based on a variable, you must use Python. Look at the first half of this: http://plone.org/documentation/how-to/addContentProgrammatically --jcc -- "Building Websites with Plone" http://plonebook.packtpub.com
Jason C. Leach wrote:
Hi,
I'm wondering how I can do this little trick (sp_info is a globaly devide var, it's a dictionary obj):
<option tal:repeat="group groups/existing/high" tal:content="group" tal:attributes="onmouseover string:doTooltip(event, '${sp_info/${group}/common_name}')" onmouseout="hideTip()"> </option>
So based on my the value of 'group' from my repeat, I want to use the value to look up another value in a different dictionary. It works if I do this: (event, '${sp_info/whatever/common_name}') but does not like me using the embedded ${group}.
Thanks, Jason.
Hi Jason, I didn't know you could nest ${} objects in a string: construct. You might make life easier using python. Maybe something like: tal:attributes="onmouseover python: sp_info[ group ] + '/' + common_name" I have no idea what "common_name" is supposed to be, here I assumed its a global var. David
<tal:repeat repeat="group groups/existing/high"> <option tal:define="js_arg python:sp_info[group];" tal:content="group" tal:attributes="onmouseover string:doTooltip(event, '${js_arg}/common_name}')" onmouseout="hideTip()"> </option> </tal:repeat> The <tal:repeat> tags are to make sure the order of TAL operations works properly with the tal:define being done *after* the tal:repeat. Hope this helps. Ross
Jason C. Leach wrote:
Hi,
I'm wondering how I can do this little trick (sp_info is a globaly devide var, it's a dictionary obj):
<option tal:repeat="group groups/existing/high" tal:content="group" tal:attributes="onmouseover string:doTooltip(event, '${sp_info/${group}/common_name}')" onmouseout="hideTip()"> </option>
So based on my the value of 'group' from my repeat, I want to use the value to look up another value in a different dictionary. It works if I do this: (event, '${sp_info/whatever/common_name}') but does not like me using the embedded ${group}.
You can insert the value of a dynamically named variable using the '?' specifier:: tal:attributes="onmouseover string:doTooltip(event, '${sp_info/?group/common_name}')" should do the trick. This only works inside path expressions. Hth, Michael -- http://zope.org/Members/d2m http://planetzope.org
Hi Jason, I see a few people have had a stab at this, but I have a feeling I know what you really meant ;-) Jason C. Leach wrote:
I'm wondering how I can do this little trick (sp_info is a globaly devide var, it's a dictionary obj):
<option tal:repeat="group groups/existing/high" tal:content="group" tal:attributes="onmouseover string:doTooltip(event, '${sp_info/${group}/common_name}')" onmouseout="hideTip()"> </option>
So based on my the value of 'group' from my repeat, I want to use the value to look up another value in a different dictionary. It works if I do this: (event, '${sp_info/whatever/common_name}') but does not like me using the embedded ${group}.
try this: <tal:i repeat="group groups/existing/high"> <option tal:define="event sp_info/?group/common_name" tal:content="group" tal:attributes="onmouseover string:doTooltip(event,'$event')" onmouseout="hideTip()"> </option> </tal:i> cheers, Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
participants (6)
-
Chris Withers -
David H -
J Cameron Cooper -
Jason C. Leach -
Michael Haubenwallner -
Ross Patterson