In this second article, dive a little deeper into theintricacies of DTML by getting up close and personal with conditionalstatements and comparison operators. This article discusses thedifferent variants of the "if" statement available in DTML, togetherwith examples and code listings that demonstrate how they can be used ina Web applications.
As you can see, this is simply a form which allows you to pick a day ofthe week.
The real work is done by the DTML Method "showMovieForTheDay".
Here is the movie for <dtml-var day> on your favorite channel:
<dtml-if expr="day == 'Monday'">
<p><b>Dead By Monday</b> - directed by <b>Curt Truninger</b>
expr="day == 'Tuesday'"> <p><b>Never On Tuesday</b> - directed by
<b>Adam Rifkin</b></p> <dtml-elif expr="day == 'Wednesday'"> <p><b>Any
Given Wednesday</b> - directed by <b>Neil Mandt</b></p> <dtml-elif
expr="day == 'Thursday'"> <p><b>Thursday Afternoon</b> - directed by
<b>Clay Westervelt</b></p> <dtml-elif expr="day == 'Friday'">
<p><b>Friday The 13th</b> - directed by <b>Sean S. Cunningham</b></p>
<dtml-else> <p><b>Hey, Mr. Couch Potato! It's the weekend...go out
get some exercise!</b></p> </dtml-if> <br>
In this case, we've used the "if-elif-else" control structure to displaythe appropriate move for the day.
There's one important point to be noted here: as soon as one of the"if"statements within the block is found to be true, Zope will execute thecorresponding code, skip the remaining "if" statements in the block,andjump immediately to the lines following the entire "if-elif-else"block.