Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Number Formatting in .tpl files

 
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
FrankinHolland
Smarty Rookie


Joined: 19 Jul 2011
Posts: 14

PostPosted: Tue Mar 20, 2012 11:17 pm    Post subject: Number Formatting in .tpl files Reply with quote

Hi all,

Is there any way to format number output in .tpl files? I tried the few examples on the site with no success. The output I want to modify is here:

<td height="17" class="redmatter">Price: {if $FeaturedProduct[i].dPrice neq ""}{$FeaturedProduct[i].dPrice}{/if}</td>

I want to format the $FeaturedProduct[i].dPrice like $1,000 for example

Thanks very much.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4587
Location: Hamburg / Germany

PostPosted: Wed Mar 21, 2012 5:24 pm    Post subject: Reply with quote

See the string format modifier
http://www.smarty.net/docs/en/language.modifier.string.format.tpl
Back to top
View user's profile Send private message
FrankinHolland
Smarty Rookie


Joined: 19 Jul 2011
Posts: 14

PostPosted: Wed Mar 21, 2012 6:08 pm    Post subject: Thanks again! Reply with quote

I can't tell you how much I have appreciated your help.
Back to top
View user's profile Send private message
FrankinHolland
Smarty Rookie


Joined: 19 Jul 2011
Posts: 14

PostPosted: Wed Mar 21, 2012 6:22 pm    Post subject: Is there a plugin required? Reply with quote

Sorry if this is a newbie question but I am getting the following error:

Fatal error: require_once() [function.require]: Failed opening required 'SMARTY_CORE_DIRcore.load_plugins.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xxxx/public_html/xxxx.xxx/templates_c/%%609^%%609278444^home.tpl.php on line 3
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4587
Location: Hamburg / Germany

PostPosted: Wed Mar 21, 2012 6:50 pm    Post subject: Reply with quote

Delete all files in the ....../template_c/ folder and retry.

Looks like that the constant SMARTY_CORE_DIR was not defined correctly when the temlates got compiled.
Back to top
View user's profile Send private message
FrankinHolland
Smarty Rookie


Joined: 19 Jul 2011
Posts: 14

PostPosted: Wed Mar 21, 2012 7:33 pm    Post subject: SMARTY_CORE_DIR? Reply with quote

Still getting the same error. This is what is triggering it:

{$FeaturedProduct[i].dPrice|string_format:"%.2f"}

I will look up info on SMARTY_CORE_DIR and double check my settings. Thanks again for your input.
Back to top
View user's profile Send private message
FrankinHolland
Smarty Rookie


Joined: 19 Jul 2011
Posts: 14

PostPosted: Mon Mar 26, 2012 10:49 pm    Post subject: CORE path issues Reply with quote

Something is wrong with my CORE files. Working on it.... Thanks for pointing me in the right direction. Smile
Back to top
View user's profile Send private message
FrankinHolland
Smarty Rookie


Joined: 19 Jul 2011
Posts: 14

PostPosted: Tue Mar 27, 2012 5:18 pm    Post subject: Resolved Reply with quote

I deleted all my Smarty files and reloaded 2.6.26 and that seems to have resolved the problem. I had mixed files and the core vs. internals\core seems to have been the problem. I want to upgrade to 3.1.8 but I don't feel like I have complete control over the site yet so I will be doing this slowly. Thanks again for your help.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests 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