[ZPT] How do I...
Tony McDonald
tony.mcdonald@ncl.ac.uk
Thu, 17 May 2001 08:06:04 +0100
Ok,
I've gone through the archives, read the messages and scanned the Wiki.
I'm stuck.
I'm coming from a DTML background (and python) and trying to get a handle on
various things I'm used to doing in DTML.
If people could tell me how to do these two tasks, I'd be very happy.
1) I want to use the 'odd' path component to switch the background colour of
a table row. I have this at the moment;
<table>
<tr tal:attributes="bgcolor string:bogus${repeat/item/odd}"
tal:repeat="item python:container.module_info(module_code='bgm')"
bgcolor><td tal:content="repeat/item/index">index number</td><td
tal:content="item/module_code">module Code</td><td
tal:content="item/faculty">faculty</td><td
tal:content="item/module_title">module title</td></tr>
</table>
(module_info is a ZSQL method)
Which yields this
<tr bgcolor="bogus0">
<td>0</td><td>BGM001</td><td>ME</td><td>Biochemistry for Medicinal and
Foundation Chemists</td></tr>
<tr bgcolor="bogus1">
<td>1</td><td>BGM100</td><td>ME</td><td>Biomolecules and Cell
Biology</td></tr>
etc
etc
What I'd like to do is have bogus0 = blue and bogus1 = red (or whatever).
What's the preferred way of doing this?
2) I'd also like to call the above PageTemplate from DTML, substituting the
module_code='bgm' above with module_code=modcode, and pass modcode into the
PageTemplate. I'm using this code;
tal:repeat="item python:container.module_info(module_code=request/modcode)"
Unfortunately the standard idiom
<dtml-var "mod_info(_.None,_,modcode='bgm')">
Returns an error:
Error Type: TALESError
Error Value: exceptions.NameError on modcode in ""
Can anyone tell me where I'm going wrong (on 2) and suggest how I can do
(1)?
Thanks
Tone.
--
Dr Tony McDonald, Assistant Director, FMCC, http://www.fmcc.org.uk/
The Medical School, Newcastle University Tel: +44 191 243 6140
A Zope list for UK HE/FE http://www.fmcc.org.uk/mailman/listinfo/zope