Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
PHP Smarty and money_format

 
Post new topic   Reply to topic    Smarty Forum Index -> Documentation
View previous topic :: View next topic  
Author Message
blake
Smarty n00b


Joined: 14 Apr 2012
Posts: 3

PostPosted: Sat Apr 14, 2012 9:15 pm    Post subject: PHP Smarty and money_format Reply with quote

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


Joined: 16 Apr 2003
Posts: 7238
Location: Lincoln Nebraska, USA

PostPosted: Sat Apr 14, 2012 10:11 pm    Post subject: Reply with quote

post example?
Back to top
View user's profile Send private message Visit poster's website
blake
Smarty n00b


Joined: 14 Apr 2012
Posts: 3

PostPosted: Sat Apr 14, 2012 10:17 pm    Post subject: Reply with quote

{$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
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7238
Location: Lincoln Nebraska, USA

PostPosted: Sat Apr 14, 2012 10:23 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
blake
Smarty n00b


Joined: 14 Apr 2012
Posts: 3

PostPosted: Sat Apr 14, 2012 10:29 pm    Post subject: Reply with quote

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


Joined: 16 Apr 2003
Posts: 7238
Location: Lincoln Nebraska, USA

PostPosted: Sat Apr 14, 2012 10:31 pm    Post subject: Reply with quote

If the plugin exists it should find it first. You can also do this:

{"format"|money_format:$money}

that should work.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Documentation 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