|
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 |
Demerzel Smarty Rookie
Joined: 31 Jan 2010 Posts: 26
|
Posted: Sun Sep 25, 2011 7:02 pm Post subject: number to words |
|
|
whether it is possible to change numbers to words.
For example to make smarty write "two" when varible is 2? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Sun Sep 25, 2011 8:17 pm Post subject: |
|
|
write a modifier that changes numbers to words. |
|
Back to top |
|
Demerzel Smarty Rookie
Joined: 31 Jan 2010 Posts: 26
|
Posted: Mon Sep 26, 2011 5:47 pm Post subject: |
|
|
Your answer is so instructive, You could just as well not waste the time to write anything. |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Sep 26, 2011 6:54 pm Post subject: |
|
|
Demerzel wrote: | Your answer is so instructive, You could just as well not waste the time to write anything. |
Ok I'll elaborate. Yes it is possible, but first you need a PHP function that changes numbers to words, something like number2word($number) {...} (If you have trouble writing that, there are plenty of general PHP developer sources around the web.) Once you have that accomplished, you can write a plugin (modifier) to run your variable through that function such as {$myvar|num2word}. The instructions for how to implement a modifier plugin are very clearly defined in the online documentation.
You could also search and see if this has been done before, which it appears jacz has done this work for you.
Is that more helpful? |
|
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
|