Wade Preston Shearer wrote:
I consider your example breaking the separation of business and display
logic. The front-end should only have display logic; it shouldn't be
performing calculations. You have business logic in your example. The
backend should take care of that and only pass variables and arrays to
the front-end.
The front-end could (should) look like this:
<select name="day">
<? foreach ($days as $day) { ?>
<option value="<? $day ?>"><? $day ?></option>
<? } ?>
</select>
<select name="month">
<? foreach ($months as $month) { ?>
<option value="<? $month ?>"><? $month ?></option>
<? } ?>
</select>
<select name="year">
<? foreach ($years as $year) { ?>
<option value="<? $year ?>"><? $year ?></option>
<? } ?>
</select>
I agree. I should have put in a better example. But I still think...
{html_select_date time="$begDate" prefix="begDate" start_year="2001"
end_year="+1"}
... is more readable. Not only is the pure PHP snippet above ~15 lines
longer, that doesn't even include the application logic. Nitpicky
detail: Your snippet doesn't have any selected options, whereas the
Smarty code does ($begDate). So there'd be even more PHP tags and vars
in the mix, with conditionals.
But html_select_date is really just some of the icing on the cake. I'd
still use it even if it only had control flow and modifiers.
_______________________________________________
UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net