Adding PHP Variables Listed In Smarty Template Page
Posted: Sat Jun 14, 2008 6:02 pm
Hey,
I'm trying to get 2 values that I have listed in a smarty template from Amember membership software to add up.
For instance, in the smarty template page, this line of code:
{$d.sales|string_format:"%d"}
= # of sales. This comes from a db query I create. Ok, so to the user let's say that value is '5' when they look at the page
And the next line is:
{$d.uniq|string_format:"%d"}
= # of unique VIEWS.
All I want to do is a legal math function (division) within the smarty template, such as
$div_ratio = {$d.sales|string_format:"%d"} / {$d.uniq|string_format:"%d"}
print $div_ratio;
So, within the smarty template would be a variable that divides these 2 lines of code to create a dividend for the user to view.
But when I try to turn them into variables within the smarty template, it breaks a million times.
Is it POSSIBLE to add/subtract/divide values WITHIN the smarty template html page or must EVERYTHING be done within the php pages that display them?
Thanks
I'm trying to get 2 values that I have listed in a smarty template from Amember membership software to add up.
For instance, in the smarty template page, this line of code:
{$d.sales|string_format:"%d"}
= # of sales. This comes from a db query I create. Ok, so to the user let's say that value is '5' when they look at the page
And the next line is:
{$d.uniq|string_format:"%d"}
= # of unique VIEWS.
All I want to do is a legal math function (division) within the smarty template, such as
$div_ratio = {$d.sales|string_format:"%d"} / {$d.uniq|string_format:"%d"}
print $div_ratio;
So, within the smarty template would be a variable that divides these 2 lines of code to create a dividend for the user to view.
But when I try to turn them into variables within the smarty template, it breaks a million times.
Is it POSSIBLE to add/subtract/divide values WITHIN the smarty template html page or must EVERYTHING be done within the php pages that display them?
Thanks