[FX.php List] Formatting numbers in FX.php

DC dan.cynosure at dbmscan.com
Fri Mar 3 14:06:05 MST 2006


this is exactly the kind of thing that led me to Smarty.
http://smarty.php.net

and my page on the wiki (which is getting a bit long in the tooth):
http://smarty.incutio.com/?page=SmartyFilemakerPro

smarty allows you to "apply a modifier" to any variable in the HTML 
template. modifiers are very simple processing commands that perform 
nifty formatting tricks like these:

capitalize
cat
count_characters
count_paragraphs
count_sentences
count_words
date_format
default
escape
indent
lower
nl2br
regex_replace
replace
spacify
string_format
strip
strip_tags
truncate
upper
wordwrap

you can also use *any* PHP function as a modifier like so:
{$variable|number_format}

Smarty gives you fine grained control for nice formatting in HTML 
templates, but also, caching of database results; we all know how slow 
FMP can be under some circumstances.

here's one simple way to use it with FX results:
click on Basic Example when you get there...
http://dbmscan.com/snippets/?cat_select=FX_and_Smarty

this example has lots of comments to help you understand smarty 
templates (i even put the number_format in this example).

guaranteed, your development will never be the same again! smarty is 
like a breath of fresh air after mixing and mashing PHP code and HTML 
together.

go to the crash course at the smarty site and get started... you'll be 
happy you did.

dan

Allyson Olm had written:
> Hi Bob,
> 
> You can use number_format()
> 
> Ex.
> 
> $num = 125489;
> echo number_format($num);
> 
> In kindness,
> Allyson Olm
> FMWebschool
> http://www.fmwebschool.com
> -----Original Message-----
> From: fx.php_list-bounces at mail.iviking.org
> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Bob Patin
> Sent: Friday, March 03, 2006 1:08 PM
> To: FX.php Discussion List
> Subject: [FX.php List] Formatting numbers in FX.php
> 
> Hi list,
> 
> Is there a way to get FX.php to return the formatting that FileMaker  
> uses with numbers? In CDML, I could just add ",format" to a tag to  
> have a number displayed using the same formatting as the database  
> itself.
> 
> For example, with a number like 12000, I'd like it to display as  
> "12,000"; I'm hoping not to have to write a calc script to insert  
> commas or dollar signs.
> 
> Does such a beast exist? Failing that, does anyone have a calc  
> they've already done that will format my number with thousands  
> separators?
> 
> Thanks a lot,
> 
> Bob Patin
> Longterm Solutions
> bob at longtermsolutions.com
> 615-333-6858
> http://www.longtermsolutions.com
> 
>    CONTACT US VIA SKYPE:
>       USERNAME: longtermsolutions
> 
>    CONTACT US VIA INSTANT MESSAGING:
>       AIM or iChat: longterm1954
>       Yahoo: longterm_solutions
>       MSN: bob at patin.com
>       ICQ: 159333060
> 
> 
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> 
> 
> 
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 


More information about the FX.php_List mailing list