[Zope] Selection and Lines Properties for DTML Docs

Tim Cook twcook@iswt.com
Tue, 02 Jan 2001 12:58:31 -0600


Steve McMahon wrote:
> 
> I'm new to Zope and am interested in the use of document properties
> for separating content and design in documents (i.e., using <dtml-var
> prop_name> in the "edit" tab to insert properties defined on
> the "properties" tab>.
> 
> I've had success with simple text properties and would like to be
> able to present the user with selection properties (choice 1, choice
> 2, ...). That works well when I first define a "lines" property, then
> a "selection" property. But, what I'd really like to do is hide the
> lines property from the user. I've tried putting a lines property in
> another document, then setting the selection value
> to 'source_doc.lines_prop'. That yields an error "No select variable
> source_doc.lines_prop."
> 
> Any ideas on the right way to do this? Please feel free to point me
> to good documentation!


In order to give users a set of configurable options throughout
the application this is what I did.

In the root folder of the application I defined a lines type
property for each option. For example, telephone number types
(home, work, cell etc.) 

The selection looks like this:
<tr><td>Phone Type: </td><td>
<SELECT name="phone_type">
  <dtml-in valid_phone_types>
    <OPTION value="<dtml-var sequence-item>"><dtml-var
sequence-item></OPTION>
   </dtml-in>
</SELECT>
</td></tr>

The DTML Method valid_phone_types just returns a list of what it
found in the phone_types property:

<dtml-call expr="REQUEST.set('the_list', [])">
  <dtml-in phone_types>
     <dtml-let current_item=sequence-item>
       <dtml-call expr="the_list.append(current_item)">
     </dtml-let>
   </dtml-in>
<dtml-return the_list>





This is the form entry for the user to edit the lines property.
Note it is in a table with others but the key thing to look at is
the way the line break is in the middle of the 'dtml-var'. If you
don't do this you will end up with extra/empty lines in your
property.

<tr>
<td valign="middle"><b>Phone Types:</b></td>

<td><textarea name="phone_types:lines" rows="10" cols="30" >
<dtml-in phone_types><dtml-let cur_item=sequence-item><dtml-var 
"_.string.strip(cur_item)">
</dtml-let></dtml-in>
</textarea>
</td>
</tr>


HTH,

-- Tim Cook, President --
Free Practice Management,Inc. | http://www.FreePM.com
Office: (901) 884-4126
Censorship: The reaction of the ignorant to freedom.