How to assign a value to a dtml variable after it has been create d with the let dtml tag ?
Hello, In the piece of DTML code here after, I'm trying to compare each element of getAllPortalCategories() with each of getCategories(). I would like to have each element as a selected option in the generated HTML if this element is in both lists. Here the error I get is that Zope searches for a variable named 'false'. I would want Zope considers 'false' as a string value assigned to isSelected, not as a var to search. But my problem is more general: how can I modify the value of a dtml variable? <tr> <th align="LEFT" valign="TOP">Categories (current ones are selected)</th> </tr> <td align="LEFT" valign="TOP"> <select multiple name="categories:list" size=10> <dtml-in expr="getAllPortalCategories()"> <dtml-let aPortalCategory=sequence-item isSelected='false'> <dtml-in expr="getCategories()"> <dtml-if expr="aPortalCategory == _['sequence-item']"> _['isSelected']='true' </dtml-if> </dtml-in> <dtml-if expr="_[isSelected]=='true'"> <option selected> <dtml-var aPortalCategory> </option> <dtml-else> <option> <dtml-var aPortalCategory> </option> </dtml-if> </dtml-let> </dtml-in> </td> Thanks in advance, Philippe
Bocquillon Philippe writes:
.... I would want Zope considers 'false' as a string value assigned to isSelected, not as a var to search. <dtml-let aPortalCategory=sequence-item isSelected='false'> <dtml-let aPortalCategory=sequence-item isSelected="'false'">
... assigning to DTML variables ... You can not do that.
You can use "REQUEST" to emulate such variables: <dtml-call "REQUEST.set('your_varname',value)"> .... <dtml-var "... your_varname ..."> You must be careful, to choose 'your_varname' in such a way that there are no name conflicts, as REQUEST variables have quite a low priority in lookup. Dieter
participants (2)
-
Bocquillon Philippe -
Dieter Maurer