Re: [SMARTY] "if" with "or"-problem
| From: | messju mohr | Date: | Thu, 03 Apr 2003 17:24:51 +0000 |
| Subject: | Re: [SMARTY] "if" with "or"-problem | ||
| References: | 1 2 3 4 5 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-9059@lists.php.net to get a copy of this message | ||
On Thu, Apr 03, 2003 at 02:36:40PM +0200, Matthias Mohr wrote:
> >> {if $Flag1|default:0 eq 1 or $Flag2|default:1 eq 1}
> > > Does the default-modifier don't work correct?
> > > Or am I doing something wrong?
> >
> > it depends on what you would consider "correct".
> >
> > default uses the default value for the integer 0 (or the boolean
> > false), but not for the string "0".
> So if Flag2 is assigned to 0, the modifier default thinks, it is not
> set and therefore it sets it to the string "1"?
>
> > so if you do
> > $smarty->assign( "Flag1", "0" );
> > $smarty->assign( "Flag2", "0" );
> >
> > "false" is printed.
> Yes, you're right :-)
>
> > but be aware: if you do {assign var=Flag2 value=0}, $Flag2 is a string
> > not an int. smarty treats all plugin-parameters as strings.
> So it's a difference between assigning variables with PHP and assigning
> through the assign-function inside smarty?
> In PHP there is a difference between
> $smarty->assign( "Flag1", 0 )
> and
> $smarty->assign( "Flag1", "0" )
> ?
> And
> {assign var="Flag1" value=0}
> {assign var="Flag1" value="0"}
> are the same (both assign a string)?
>
> In my oppinion you should change the behaviour of the smarty-assign function,
> so that it will do the same as the PHP version (or vice versa :-))
okay, i committed a change that distinguishes between foo="0" and
foo=0 in the plugin-paramters-list.
if anybody thinks this could break any (reasonable in this context)
backwards-compatibility: stand up now and cry "here!" . :)
> with regards,
> Matthias