|
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 |
blake Smarty n00b
Joined: 14 Apr 2012 Posts: 3
|
Posted: Sat Apr 14, 2012 9:15 pm Post subject: PHP Smarty and money_format |
|
|
I been trying to use money format but everytime I use it it keeps complaining that my var is not a double but a string even though it's been casted double set HAS a double manually. I mean damn. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Apr 14, 2012 10:11 pm Post subject: |
|
|
post example? |
|
Back to top |
|
blake Smarty n00b
Joined: 14 Apr 2012 Posts: 3
|
Posted: Sat Apr 14, 2012 10:17 pm Post subject: |
|
|
{$money|money_format:"%(#10n"}
I think it's a php smarty bug, even if I create a custom modifier for money_format it still errors but when I copy it and call it money modifier it works perfectly. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Apr 14, 2012 10:23 pm Post subject: |
|
|
money_format is a php function. Therefor when you call in a smarty template:
{$money|money_format:$format}
This effectively calls in PHP:
money_format($money,$format)
however, money_format() expects the format first, not the value. So you either need to make a smarty plugin wrapper, or in Smarty 3 you can do:
{money_format($format,$money)} |
|
Back to top |
|
blake Smarty n00b
Joined: 14 Apr 2012 Posts: 3
|
Posted: Sat Apr 14, 2012 10:29 pm Post subject: |
|
|
Will I created my own modifier money_format but it keeps calling the php function has you said instead of my custom modifier. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sat Apr 14, 2012 10:31 pm Post subject: |
|
|
If the plugin exists it should find it first. You can also do this:
{"format"|money_format:$money}
that should work. |
|
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
|