[ beno]
[ beno]
I know one cannot nest DTML objects, but the below lets you know what I'm trying to accomplish. What is the correct syntax?
<dtml-let folder="<dtml-var id>">
<dtml-let folder=id>
That simple. Thanks. But I'm still not home free. Here's my code:
<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in objectValues> <dtml-let folder=id> <dtml-if expr="folder[2:]==lang[2:]"> <dtml-call "REQUEST.set('approved', '[lang]')"> <dtml-var approved> </dtml-if> </dtml-let> </dtml-in> </dtml-let>
It prints this: *[lang]*. I need it to print the value of the variable. How do I do that?
Sure, '[lang]' is just a string, so that is what it prints. The variable you created is lang, so you just write <dtml-call "REQUEST.set('approved', lang)"> BTW, I would simplify (just shorter and easier to read, not otherwise better) these lines: <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-if expr="folder[2:]==lang[2:]"> to <dtml-let lang="REQUEST['HTTP_ACCEPT_LANGUAGE']"> <dtml-if "folder[2:]==lang[2:]"> Cheers, Tom P
Passin, Tom wrote:
BTW, I would simplify (just shorter and easier to read, not otherwise better) these lines:
<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')">
to
<dtml-let lang="REQUEST['HTTP_ACCEPT_LANGUAGE']">
Hi, I'm not sure, if the second solution should be recommended at all... If HTTP_ACCEPT_LANGUAGE is not set in the REQUEST at all, REQUEST['HTTP_ACCEPT_LANGUAGE'] will raise an key-error, while the first one still works. lang will be simply None this way. Maybe even better is: <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE','en')"> So lang "defaults" to a 'en' as standard-language-if-no-other-language-is-given and your further code won't break if lang is None...;) Cheers, Maik
At 12:20 AM 1/15/2003 +0100, you wrote:
Passin, Tom wrote:
BTW, I would simplify (just shorter and easier to read, not otherwise better) these lines: <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> to <dtml-let lang="REQUEST['HTTP_ACCEPT_LANGUAGE']">
Hi,
I'm not sure, if the second solution should be recommended at all... If HTTP_ACCEPT_LANGUAGE is not set in the REQUEST at all, REQUEST['HTTP_ACCEPT_LANGUAGE'] will raise an key-error, while the first one still works. lang will be simply None this way. Maybe even better is:
<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE','en')">
So lang "defaults" to a 'en' as standard-language-if-no-other-language-is-given and your further code won't break if lang is None...;)
Well, actually, that just made things a whole heck of a lot easier!!! Thanks :) beno
participants (3)
-
beno -
Maik Jablonski -
Passin, Tom