if statements

[email protected] (Andrei Zmievski)
Newsgroups php.template
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.