How to pass parameters to a dtml method
This how-to takes you through creating a dtml-method which takes a parameter, and calling it.
Create a dtml method with:
Student Name: <dtml-var student_name>
Calling the method
Create a dtml-method with:
<dtml-var standard_html_header> <dtml-var "dtmlStudent(_.None, _, student_name='Harry')"> <dtml-var standard_html_footer>
Yes, the bit with ...var dtmlStudent(.None, , ... looks ugly and complicated, and you may not even find it necessary to use every time. For example, you can get away with dtmlStudent(student_name='Harry). I found using the canonical form consistently better and as your programming skills develop, you find that the syntax above will save you a lot of grief.
Alternative (new April 10, 2002)
I was alerted by an unknown reader that the
following code works too. I haven't tested it,
but it should work, since the current dtml page's
namespace is passed to dtmlStudent in the
<dtml-var standard_html_header> <dtml-let student_name="'Harry'"> <dtml-var dtmlStudent> </dtml-let> <dtml-var standard_html_footer>