Hi, Tres Seaver (thanks) gave me the following code to lookup a photo in the namespace based on a value from a field (mwid) in a database. <dtml-with psychologie> <dtml-with mwfoto> <dtml-if "_.has_key(mwid)"> <dtml-var "_[mwid].tag()"> <dtml-else> <dtml-var "geenfoto.tag()"> </dtml-if> </dtml-with> </dtml-with> This should work but it doesn't. This however works (replacing mwid by a fixed value). <dtml-with psychologie> <dtml-with mwfoto> <dtml-if "_.has_key('linde')"> <dtml-var "_['linde'].tag()"> <dtml-else> <dtml-var "geenfoto.tag()"> </dtml-if> </dtml-with> </dtml-with> I found out that using mwid with <dtml-if "_.has_key(mwid)"> <dtml-var "_[mwid].tag()"> one space is added to mwid, so I get 'linde '. This space is not in the database, or generated by the database, I guess, because this works fine: <img src="/psychologie/mwfoto/<dtml-var mwid>" align="right"> So what is happening here? How do I use the (r)strip function in an expression like <dtml-if "_.has_key(mwid)">. Your help is much apreciated. Henny van der Linde Leiden University Netherlands linde@fsw.leidenuniv.nl
----- Original Message ----- From: H.G.J. van der Linde <linde@fsw.leidenuniv.nl>
I found out that using mwid with
<dtml-if "_.has_key(mwid)"> <dtml-var "_[mwid].tag()">
one space is added to mwid, so I get 'linde '. This space is not in the database, or generated by the database, I guess, because this works fine:
<img src="/psychologie/mwfoto/<dtml-var mwid>" align="right">
Not conclusive. The browser might be perfectly happy to strip off the trailing space. Try <dtml-var expr="_.len(mwid)"> to see for sure.
How do I use the (r)strip function in an expression like <dtml-if "_.has_key(mwid)">.
You can <dtml-if expr="_.has_key(string.strip(mwid))"> and <dtml-var expr="_[string.strip(mwid)].tag()"> Cheers, Evan @ digicool
participants (2)
-
Evan Simpson -
H.G.J. van der Linde