菜单

typoscript numberFormat

2011年06月14日 - typoscript

Calls the PHP function number_format
Allows you to format numbers
Note: TYPO3 v4.5 introduces a stdWrap property numberFormat. In order to avoid conflicts, the extension disables its own stdWrap property described below.Converting a number to localized Euro value


To display an amount of Euros in German number format:
lib.currency = TEXT
lib.currency.value = 1020.35
lib.currency.numberFormat = 1
lib.currency.numberFormat.decPoint = ,
lib.currency.numberFormat.thousandsSep = .
lib.currency.numberFormat.decimals = 2
lib.currency.noTrimWrap = || EUR|
Converting a file size to a localized value
The extension also allows you to convert the decimal point of byte values:
lib.bytes = TEXT
lib.bytes.value = 12345435345
lib.bytes.bytes = 1
lib.bytes.bytes.labels =  | KB | MB | GB | TB
lib.bytes.bytes.decPoint = ,
This is a special replacement that will replace all occurences of . By the decPoint-value. If you want a complex wrap (say a sentence), please use the following formula:
lib.bytes = COA
lib.bytes.10 = TEXT
lib.bytes.10.value = The file is taking up
lib.bytes.10.noTrimWrap = || |
lib.bytes.20 = TEXT
lib.bytes.20.value = 12345435345
lib.bytes.20.bytes = 1
lib.bytes.20.bytes.labels =  | KB | MB | GB | TB
lib.bytes.20.bytes.decPoint = ,
lib.bytes.30 = TEXT
lib.bytes.30.value = of disk space.
lib.bytes.30.noTrimWrap = | ||
TS that works for all TYPO3 versionsIf you maintain several sites with the same TS code, but different versions, you can still use numberFormat:
lib.currency = TEXT
lib.currency.value = 1020.35
lib.currency.numberFormat = 1
lib.currency.numberFormat.decPoint = ,
lib.currency.numberFormat.thousandsSep = .
lib.currency.numberFormat.dec_point = ,
lib.currency.numberFormat.thousands_sep = .
lib.currency.numberFormat.decimals = 2
This code will work both in TYPO 4.5 and lower versions.

发表评论

电子邮件地址不会被公开。 必填项已用*标注