Re: if statements

From: Date: Tue, 15 Feb 2000 22:15:15 +0000
Subject: Re: if statements
References: 1  Groups: php.template 
Request: Send a blank email to php-template+get-55@lists.php.net to get a copy of this message
I think ifs are somewhat evil. The same could be done with: Your search found {products_total} {match_plural}. Thus, the plurality logic remains in the PHP code. One argument against this is that it does not internationalize well. I don't have a good answer for that offhand. -dan Andrei Zmievski wrote: > 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.

Attachment: [text/x-vcard] Card for Dan Libby danda.vcf
« previous php.template (#55) next »