Visualizzare numero con separazione migliaia

La discussione sul CMS Made Simple in italiano.

Moderator: magallo

Post Reply
User avatar
protempore
Power Poster
Power Poster
Posts: 599
Joined: Mon Jan 14, 2008 9:08 pm

Visualizzare numero con separazione migliaia

Post by protempore »

ciao,
mi sono perso in un bicchier d'acqua... ma mi sa che faccio prima a chiederlo qui...  ;)

come faccio a visualizzare un numero con il punto di separazione delle migliaia?

con il modificatore Smarty "|string_format:"%d" posso determinare il numero dei decimali, ma per le migliaia? devo fare un UDT apposta? non c'è già qualcosa in Smarty?... io non lo trovo.
An eye for an eye will make the whole world blind
Mahatma Gandhi (1869-1948)
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

Re: Visualizzare numero con separazione migliaia

Post by blast2007 »

Code: Select all

{assign var=mynumber value="1000"}
{$mynumber|number_format:0:",":"."}
Risultato 1.000

La funzione php è number_format

ciao
blast
User avatar
protempore
Power Poster
Power Poster
Posts: 599
Joined: Mon Jan 14, 2008 9:08 pm

Re: Visualizzare numero con separazione migliaia

Post by protempore »

blast2007 wrote:

Code: Select all

{assign var=mynumber value="1000"}
{$mynumber|number_format:0:",":"."}
Risultato 1.000

La funzione php è number_format

ciao
blast
o porca paletta... io il modificatore Smarty "number_format", qui non lo trovo proprio... mi ero fatto un UDT proprio usando la funzione PHP che hai detto...

non è che non ho capito quando bisogna costruirsi degli UDT?
:-\
Last edited by protempore on Fri Jul 31, 2009 8:51 am, edited 1 time in total.
An eye for an eye will make the whole world blind
Mahatma Gandhi (1869-1948)
User avatar
blast2007
Power Poster
Power Poster
Posts: 508
Joined: Wed Aug 01, 2007 5:36 pm

Re: Visualizzare numero con separazione migliaia

Post by blast2007 »

Dal manuale di smarty
Variable modifiers can be applied to variables, custom functions or strings. To apply a modifier, specify the value followed by a |  (pipe) and the modifier name. A modifier may accept additional parameters that affect its behavior. These parameters follow the modifer name and are separated by a : (colon). Also, all php-functions can be used as modifiers implicitly (more below) and modifiers can be combined. .
Puoi usare qualunque funzione php come modifier.

L'UDT te lo costruisci per scrivere codice non ottenibile con funzioni standard.

ciao
blast
User avatar
protempore
Power Poster
Power Poster
Posts: 599
Joined: Mon Jan 14, 2008 9:08 pm

Re: Visualizzare numero con separazione migliaia

Post by protempore »

blast2007 wrote:
Puoi usare qualunque funzione php come modifier.

L'UDT te lo costruisci per scrivere codice non ottenibile con funzioni standard.

ciao
blast
GRANDE! questa possibilità non l'avevo proprio capita... grazie per la dritta!
:D
An eye for an eye will make the whole world blind
Mahatma Gandhi (1869-1948)
Post Reply

Return to “Italian - Italiano”