[Zope] How to assign a value to a dtml variable after it has been created with the let dtml tag ?

Shai Berger shai@aristocart.com
Wed, 08 Aug 2001 21:47:00 +0300


Hi Philippe,

General advice: Your code is getting too complicated for
dtml. You will do much better by calculating your list of
options in a Python Script.

For your first problem: The only way to specify constants
in dtml is as python expressions. So you would need

<dtml-let isSelected="'false'"> (A python expression for a string).

For what you really need: The only way you can change a variable
in dtml-let is if you can do it with an expression. An assignment
is a statement, so you can't use it in dtml. You need something
along the lines of

<dtml-let isSelected="[]"> (an empty list is false)
 <dtml-if ...>
  <dtml-call "isSelected.append(1)"> (a non-empty list is true)
 </dtml-if>
 ...

But you can do everything with
    <select multiple name="categories:list" size=10>
    <dtml-let selectedcats="getCategories()">
     <dtml-in expr="getAllPortalCategories()">
       <dtml-let aPortalCategory=sequence-item>
        <dtml-if "aPortalCategory in selectedcats">
         <option selected> <dtml-var aPortalCategory> </option>
        <dtml-else>
         <option> <dtml-var aPortalCategory> </option>            
        </dtml-if>
      ...


 
HTH,
	Shai.