Hi How come that a simple test <dtml-if "mydocid==id">blah blah</dtml-if> isn't true whereas the values seem to be the same (mydocid and id seems to contain the same string).... Twiglight zone ? -- >> WinErr: 080 Clavier introuvable - Veuillez appuyer sur n'importe quelle touche pour continuer. << Arnaud LECAT >> Email: lecat@hexanet.fr >> WWW page:www.hexanet.fr/~lecat HEXANET >> http://www.hexanet.fr Z.A. Farman sud - 9 rue Roland Coffignot BP 415 - 51689 Reims Cedex 2 - France phone: (33) 03 26 79 30 05 Fax: (33) 03 26 79 30 06
At 16:04 08/09/99 , Arnaud Lecat wrote:
Hi
How come that a simple test <dtml-if "mydocid==id">blah blah</dtml-if> isn't true whereas the values seem to be the same (mydocid and id seems to contain the same string)....
Twiglight zone ?
Sometimes id is a method, not a string. Try mydocid==_['id']. The _['id'] does a namespace lookup, which includes a call to id if id is a method. This way it'll work wether or not id is a string. -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
id is ok for me... it contains the good string A simple display test for *<dtml-var mydocid>*<dtml-var id>* gives me *design*design* And <dtml-if "mydocid==id">blah blah</dtml-if> is not true !!! What's happening ? (* is for a purpose of display to see if there were some unwanted char in front or behind the string) Martijn Pieters wrote:
At 16:04 08/09/99 , Arnaud Lecat wrote:
Hi
How come that a simple test <dtml-if "mydocid==id">blah blah</dtml-if> isn't true whereas the values seem to be the same (mydocid and id seems to contain the same string)....
Twiglight zone ?
Sometimes id is a method, not a string. Try mydocid==_['id'].
The _['id'] does a namespace lookup, which includes a call to id if id is a method. This way it'll work wether or not id is a string.
-- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
-- >> WinErr: 080 Clavier introuvable - Veuillez appuyer sur n'importe quelle touche pour continuer. << Arnaud LECAT >> Email: lecat@hexanet.fr >> WWW page:www.hexanet.fr/~lecat HEXANET >> http://www.hexanet.fr Z.A. Farman sud - 9 rue Roland Coffignot BP 415 - 51689 Reims Cedex 2 - France phone: (33) 03 26 79 30 05 Fax: (33) 03 26 79 30 06
On Wed, 8 Sep 1999, Arnaud Lecat wrote:
id is ok for me... it contains the good string
A simple display test for *<dtml-var mydocid>*<dtml-var id>*
gives me *design*design*
And <dtml-if "mydocid==id">blah blah</dtml-if> is not true !!! What's happening ?
id is probably a method not a string. try <dtml-if "mydocid==id()">blah blah</dtml-if> ^^ I've been burned by this too. -The Dragon De Monsyne
On Wed, 8 Sep 1999, Arnaud Lecat wrote:
id is ok for me... it contains the good string
A simple display test for *<dtml-var mydocid>*<dtml-var id>*
gives me *design*design*
And <dtml-if "mydocid==id">blah blah</dtml-if> is not true !!! What's happening ?
(* is for a purpose of display to see if there were some unwanted char in front or behind the string)
What about types? May be, one object is int, another is string? Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd@emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN.
At 16:38 08/09/99 , Arnaud Lecat wrote:
id is ok for me... it contains the good string
A simple display test for *<dtml-var mydocid>*<dtml-var id>*
gives me *design*design*
And <dtml-if "mydocid==id">blah blah</dtml-if> is not true !!! What's happening ?
(* is for a purpose of display to see if there were some unwanted char in front or behind the string)
That is because <dtml-var id> will call the method id if id is a method. This is called a namespace lookup. So comparing anything to the method object 'id', will always evaluate to false. Now, you could simulate the behaviour with _['id'], which will do a namespace lookup for the object called 'id', wether it is a string or a method, and will always, in this case, return a string. You could do <dtml-if "mydocid==id()">, but then you'd make the test throw an exception for those objects where id _is_ a string. Using _['id'] will work in both cases: <dtml-if "mydocid==_['id']"> -- Martijn Pieters, Web Developer | Antraciet http://www.antraciet.nl | Tel: +31-35-7502100 Fax: +31-35-7502111 | mailto:mj@antraciet.nl http://www.antraciet.nl/~mj | PGP: http://wwwkeys.nl.pgp.net:11371/pks/lookup?op=get&search=0xA8A32149 ------------------------------------------
Arnaud Lecat wrote:
How come that a simple test <dtml-if "mydocid==id">blah blah</dtml-if> isn't true whereas the values seem to be the same (mydocid and id seems to contain the same string)....
One or the other (or both) may not be strings, but rather methods/functions which *return* a string. The cases are indistinguishable with <dtml-var v> and <dtml-var "_['v']">, but require <dtml-if "mydocid==id()"> if 'id' is a function.
Here is my full code for this. Putting id() instead of id doesn't work. mydocid has been set in the header <dtml-call "REQUEST.set('mydocid',id)"> <dtml-in "navigate_filter('donav','yes','DTML Document')"> <TR> <TD>*<dtml-var mydocid>*<dtml-var id">*</tD> <dtml-if "mydocid==id"> <TD bgcolor="#DDDDDD" width="121">1.<B><A HREF="<dtml-var absolute_url>" class="menusmalllink"><dtml-var title></A></B></TD> <dtml-else> <TD bgcolor="#DDDDDD" width="121">2.<A HREF="<dtml-var absolute_url>" class="menusmalllink"><dtml-var title></A></TD> </dtml-if> </TR> </dtml-in> Simple no ! But it doesn't work :( Evan Simpson wrote:
Arnaud Lecat wrote:
How come that a simple test <dtml-if "mydocid==id">blah blah</dtml-if> isn't true whereas the values seem to be the same (mydocid and id seems to contain the same string)....
One or the other (or both) may not be strings, but rather methods/functions which *return* a string. The cases are indistinguishable with <dtml-var v> and <dtml-var "_['v']">, but require <dtml-if "mydocid==id()"> if 'id' is a function.
-- >> WinErr: 080 Clavier introuvable - Veuillez appuyer sur n'importe quelle touche pour continuer. << Arnaud LECAT >> Email: lecat@hexanet.fr >> WWW page:www.hexanet.fr/~lecat HEXANET >> http://www.hexanet.fr Z.A. Farman sud - 9 rue Roland Coffignot BP 415 - 51689 Reims Cedex 2 - France phone: (33) 03 26 79 30 05 Fax: (33) 03 26 79 30 06
participants (5)
-
Arnaud Lecat -
Evan Simpson -
Martijn Pieters -
Oleg Broytmann -
The Dragon De Monsyne