Log in |
How to pass parameters to a dtml methodIntroductionThis how-to takes you through creating a dtml-method which takes a parameter, and calling it. DTML MethodCreate a dtml method with:
Code:
Student Name: <dtml-var student_name>
Calling the methodCreate a dtml-method with:
Code:
<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
Code:
<dtml-var standard_html_header>
<dtml-let student_name="'Harry'">
<dtml-var dtmlStudent>
</dtml-let>
<dtml-var standard_html_footer>
|