Re: [SMARTY] Re: Sub Total in smarty
| From: | Monte Ohrt | Date: | Thu, 04 Dec 2003 16:28:38 +0000 |
| Subject: | Re: [SMARTY] Re: Sub Total in smarty | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10632@lists.php.net to get a copy of this message | ||
Calculate the total in your PHP app and assign it to smarty. This business logic shouldn't be done in the templates.
Mark Mitchenall wrote:
{section name=i loop=$price} <hr> {$price[i].name} {$price[i].price} <hr> {/section} I lope through names and prices of some hardware, and I want to display total cost of all components. I dont know how to do that :( any help is appreciated.You can use {assign} for this I think... e.g. {assign var="total" value="0"} {section name=i loop=$price} <hr> {assign var="total" value="$total+$price[i].price"} {$price[i].name} {$price[i].price} <hr> {/section} Total: {$total} HTH, Mark