[Zope] calling a DTML method with arg

Thomas B. Passin tpassin@mitretek.org
Thu, 14 Feb 2002 10:56:07 -0500


[John Hunter]>
> I have several pages where I want to list some information about
> patients in my database, and want to have a single DTML method called
> listPatient which takes pid (patient id) as an arg and lists the
> information for that patient.  The basic idea is that I have many DTML
> Documents that need to list patients in a variety of contexts, and I
> want to have a single method that controls how patients are listed, so
> as I upgrade my database I won't have to change the patient listing
> format in many places
>
> Something like
>
> <dtml-in expr="get_pids()" mapping>
>     <dtml-call expr="listPatient( 'pid=%s' % <dtml-var pid>)" >
> </dtml-in>
>
> But I am having trouble figuring out how to set up a DTML method to
> get an argument like this.  Is this possible?  Can you recursively
> nest DTML methods/documents?
>

Once you are within a dtml tag, you do not need to nest dtml tags, you just
refer to things by their names, as  in

<dtml-call expr="listPatient( pid=pi)" >

This can be simplified to

<dtml-call "listPatient(pid=pi)">

Of course, "pi" has to be a variable known to the page containing the code.

Try to keep things simple whenever you can.

Cheers,

Tom P