|
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 |
4Axis Smarty n00b
Joined: 01 Sep 2015 Posts: 2
|
Posted: Tue Sep 01, 2015 8:23 am Post subject: Why "math" doesn't work? |
|
|
Hi.
I would like to multiply the variables in the TPL.
But, unfortunately, does not work and do not know why.
Code: |
{assign var="name" value=$product['name']|substr:-15}
{assign var="pos" value=$name|regex_replace:"/[\D]/":""}
{assign var="alla" value=$product['quantity']}
{$product['quantity']} --- {$pos} --- {$alla}
{math assign="span" equation="x * y" x=(int)$pos y=(int)$alla}
{$span} |
Clean $ pos = 50 and $ alla = 1, (int) $ pos = 50 and (int) $ alla = 0.
If I try math without (int) is nothing shows.
Please help |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Sep 01, 2015 8:53 am Post subject: |
|
|
Code: | <?php
require_once 'smarty-config.php';
$template = <<<'SMARTY_TEMPLATE'
{$x*$y}
SMARTY_TEMPLATE;
$tpl->assign(array('x' => 2, 'y' => 3));
$tpl->display("string:$template"); |
|
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Wed Sep 02, 2015 1:57 am Post subject: |
|
|
what version of Smarty are you using? in-line math should work fine. {$pos*$alla} |
|
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
|