|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
piropeator Smarty Rookie
Joined: 31 Oct 2007 Posts: 26
|
Posted: Wed Jul 08, 2015 9:06 pm Post subject: Sum all records without format |
|
|
I have this code in my template main.tpl : Code: | {section name=i loop=$lista}
<tr>
<td>{$lista[i]->codigoVO}</td>
<td>{$lista[i]->cargoVO}</td>
</tr>
{$importe|number_format:2:',':'.'}
{assign var="importe" value="'$importe+$lista[i]->cargoVO'"}
{/section} |
It doesnt work.
Here I show all records but I want to sum all records from $lista[i]->cargoVO and to show from $importe.
But $lista[i]->cargoVO doesnot have format (is a object).
How I do that?
thanks. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Jul 09, 2015 11:43 pm Post subject: |
|
|
Never use quotes on attribute value if it's a variable or expression.
This applies for all tags.
Code: | {assign var="importe" value=$importe+$lista[i]->cargoVO} |
|
|
Back to top |
|
piropeator Smarty Rookie
Joined: 31 Oct 2007 Posts: 26
|
Posted: Fri Jul 10, 2015 12:24 am Post subject: |
|
|
U.Tews wrote: | Never use quotes on attribute value if it's a variable or expression.
This applies for all tags.
Code: | {assign var="importe" value=$importe+$lista[i]->cargoVO} |
|
I guess its necesary to initialize the variable "importe"?. Dont you? |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri Jul 10, 2015 3:27 am Post subject: |
|
|
Yes, initialize it before the section loop. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|