Re: [SMARTY] Find in a list in an IF structure

From: Date: Thu, 28 Oct 2004 09:43:02 +0000
Subject: Re: [SMARTY] Find in a list in an IF structure
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11930@lists.php.net to get a copy of this message
On Thu, Oct 28, 2004 at 12:22:55PM +0300, Markku Niskanen wrote: > Hello, my fellow mates in pain, hurry and frustration, > > What would you recommend for a better solution for my > small Smarty problem? > > I have a fairly sophisticated class system where I generate > forms on the fly using complex sets of templates. I have several > {IF} cases where I have used multiple or's like this: > > <td valign= > {if > $fieldtypes[idx] eq "textarea" or > $fieldtypes[idx] eq "radiogroup" or > $fieldtypes[idx] eq "someother" > } > "top" > {else} > "middle" > {/if}> > {$fieldlabels[idx]}</td> > <td> > ... field generation goes here > </td> > etc... > > The above, of course, produces the correct valign > attrbute for the various field labels. What I would like to > use is a functionality like this: > > {if in_the_array($ftypes[idx], 'textarea,radiogroup,someother')} > > {else} > > {/if} just write a php-function in_the_array(). that one will called when used in {if}. > You see what I am looking for, I suppose. So is there an > internal function that might perform the "in_the_array" and return > either true or false to the "if" structure? NB: I am NOT referring to > the PHP in_array() function above. The "field types" are internal > names. > > Or is it just too few hours of sleep that prevent me from finding > the solution in the manual? > > Markku > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#11930) next »