RE: [SMARTY] problem displaying float

[email protected] ("George Pitcher") Fri, 17 Nov 2006 16:12:19 -0000
Newsgroups php.smarty.general
Message-ID <[email protected]>
Guido and Peggy,

> So what are you using to print the variable in the template?
>
> e.g.
> {$variable}
>
> Or {php}echo $variable{/php}


     $fee = [web-service response (in dollars and cents)]
     settype($fee, "float");
     $fee_type = gettype($fee);
     $range = explode(",",strim($pr));
     $rangecounter = count($range);
     $rangecounter = ($rangecounter>1?$rangecounter-1:0);
     $ccc_supp =  floatval($rangecounter * 3);
     settype($ccc_supp, "float");
     $fee2 = $fee + $ccc_supp;

 $smarty->assign('ccc_fee','The CCC QuickPrice for this request is:
 $'.sprintf("%01.2f",$fee2)."<br>$ccc_terms");

>
> Or what?
>
> And do you use any modifier for the variable, or do you just use the
> variable as assigned to?

> maybe you did not assign  $fee properly/at all...
>
> There should be a line of code in your php-script like:

> $smarty->assign('fee',$fee);

> Within your template you then state {$fee} or as messju recommended
> {"%.2f"|sprintf:$fee}
> The latter modifies a string to get the proper number of floating values
> (or however these are called)....

All is handled in PHP before assignation. I'm only asking $smarty to display
my variable.

I've been using Smarty for 3 years now - across over 20 websites and this is
the first real hassle I've encountered.

Anyway, I'm off for the weekend now.

Cheers

George