if statements

From: Date: Tue, 15 Feb 2000 21:41:22 +0000
Subject: if statements
Groups: php.template 
Request: Send a blank email to php-template+get-46@lists.php.net to get a copy of this message
Perhaps, the general feeling is that 'if' statements in templates are bad. Here's how they are useful though (taken from a template written using SmartTemplate class): <i>Your search found {products_total} {if: products_total != 1} matches. {/if} {if: products_total = 1} match. {/if} </i> To do this using only dynamic sections would make it look something like this: <i>Your search found {products_total} {section: products_total_is_1} matches. {/if} {section: products_total_is_more_than_1} match. {/if} </i> Then the developer would need to explicitly hide one of the sections. And what if there is another place on the page where some output will depend on where products_total is greater than 5, for example? Another effort on part of developer is needed. So, what are your thoughts? Are 'if' statements good or evil? -Andrei Nobody tried to design Windows - it just grew in random directions without any kind of thought behind it.

« previous php.template (#46) next »