Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Sum all records without format

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
piropeator
Smarty Rookie


Joined: 31 Oct 2007
Posts: 26

PostPosted: Wed Jul 08, 2015 9:06 pm    Post subject: Sum all records without format Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Jul 09, 2015 11:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
piropeator
Smarty Rookie


Joined: 31 Oct 2007
Posts: 26

PostPosted: Fri Jul 10, 2015 12:24 am    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Jul 10, 2015 3:27 am    Post subject: Reply with quote

Yes, initialize it before the section loop.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP