RE: [SMARTY] assigning zero
| From: | Josh Johnson | Date: | Thu, 10 Oct 2002 13:11:02 +0000 |
| Subject: | RE: [SMARTY] assigning zero | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6112@lists.php.net to get a copy of this message | ||
That's php, not smarty :)
The default modifier is 6 lines of code:
function smarty_modifier_default($string, $default = '')
{
if (empty($string))
return $default;
else
return $string;
}
the function empty() [http://www.php.net/manual/en/function.empty.php]
will evaluate to true if a value is 0. I'm sure if somebody really
wanted to they could re-write the function to take type literally (i.e.
don't print the default regardless if the value was 0 or null or
whatever, try to print a representation of that value), but the again,
why would they do something like that? :)
-- Josh
-----Original Message-----
From: webmaster@rpgateway.de [mailto:webmaster@rpgateway.de]
Sent: Thursday, October 10, 2002 5:17 AM
To: Christian@aqs-carcontrol.be; St@366ber.ws-pieter; Pieter Van Winckel
Cc: smarty
Subject: Re: [SMARTY] assigning zero
I found the problem. The problem was that I defined the variable in the
template like this :
{$content|default:""}
i deleted the default-part and now it is working. It seems that smarty
interprets 0 as no value, so that the default-value (nothing) jumped in.
Good to know for future use i guess.
cu, Christian
----- Original Message -----
From: "Pieter Van Winckel" <pvw@aqs-carcontrol.be>
To: <Christian@aqs-carcontrol.be>; <St@366ber.ws-pieter>
Cc: "smarty" <smarty-general@lists.php.net>
Sent: Thursday, October 10, 2002 8:45 AM
Subject: Re: [SMARTY] assigning zero
> On Wed, Oct 09, 2002 at 09:34:02PM +0200, Christian St?ber wrote:
> > Hi,
> >
> > I want to assign the value 0 (zero) to my template but it just does
not
> > print anything. I`m using Smarty 2.3.0. Any ideas?
> >
> > Thanks, Christian
> >
> More info please like the assing, because normally you just
> say $smarty->assign('var',0);
> >
> >
> > --
> > Smarty General Mailing List (http://smarty.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php