[Zope] Could Someone Clean This DTML Up?
Passin, Tom
tpassin@mitretek.org
Mon, 6 Jan 2003 14:18:15 -0500
[ beno]
> Okay, well here's what I've got right now...
>=20
> <dtml-let lang=3D"REQUEST.get('HTTP_ACCEPT_LANGUAGE')">
> <dtml-in objectsInTheFolder>
> <dtml-if id=3D=3D"&dtml-lang;">
> <dtml-let approved=3D"&dtml-lang;">
> <dtml-var approved>
> </dtml-let>
> <dtml-else>
> <dtml-let approved=3D"en">
> <dtml-var approved>
> </dtml-let>
> </dtml-if>
> </dtml-in>
> </dtml-let>
>=20
Beno, start simple. You can get everything else working, then deal with
objectsInTheFolder -
<dtml-let lang=3D"REQUEST['HTTP_ACCEPT_LANGUAGE']">
<dtml-in "[1,2,3]"> <!-- a simple array just for testing-->
<dtml-if "id=3D=3Dlang">
<dtml-var lang>
<dtml-else>
en
</dtml-if>
<br>
</dtml-in>
</dtml-let>
Bear in mind that "lang" is not going to be just "en" or whatever, and a
basic "en' may occur in several variations. You will probably want to
do some string processing on it before doing your comparison.
I presume that you will want to call some function or script - you were
talking about a redirect earlier. In that case, replace <dtml-var lang>
with <dtml-call "your_script(lang)">,
and replace "en" with something like <dtml-call "another_script("en"),
or use dtml-var if you want something to be displayed on the page.
Start simple until you get the basics working, and then still try to
keep things simple.
Cheers,
Tom P