For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > October 2004 > Re: [SMARTY] Find in a list in an IF structure









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

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

2004-10-28, 8:58 am

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com