게시자가 게시 한 링크에서 "맞춤 출력 수정 자 생성"헤더 아래에 출력 수정 자로 스 니펫 이름을 배치하는 방법이 나와 있습니다. 이 스 니펫은 $input
이라는 변수에 [[+MoneyField]]
값을 수신합니다.
[[your_custom_money_format_snippet ? input=`[[+MoneyField]]`]]
:
그래서 당신은
return '$'.number_format($input);
이 스 니펫을 호출하는 일을 대신 직접 때문에 같은 출력 수정 등의 또 다른 버전으로 간단 수이 사용자 정의 조각을 만들어야 할 것
이 경우 두 가지 차이점이 있는지 확실하지 않습니다. 당연히 출력 한정자 대신 스 니펫으로 호출 할 때 숫자 형식 스 니펫에 모든 값을 전달할 수 있습니다. 그리고 나는 그 둘의 성능 차가 마이크로 초라고 확신하지만 어느 것이 승리 할 지 모르겠습니다. ;)
업데이트 : 실제로이 링크에서 구현하려는 정확한 예를 발견했습니다. http://rtfm.modx.com/revolution/2.x/making-sites-with-modx/customizing-content/input-and-output-filters-%28output-modifiers%29/custom-output-filter-examples
발췌문 : 출력 수정으로 사용
<?php
$number = floatval($input);
$optionsXpld = @explode('&', $options);
$optionsArray = array();
foreach ($optionsXpld as $xpld) {
$params = @explode('=', $xpld);
array_walk($params, create_function('&$v', '$v = trim($v);'));
if (isset($params[1])) {
$optionsArray[$params[0]] = $params[1];
} else {
$optionsArray[$params[0]] = '';
}
}
$decimals = isset($optionsArray['decimals']) ? $optionsArray['decimals'] : null;
$dec_point = isset($optionsArray['dec_point']) ? $optionsArray['dec_point'] : null;
$thousands_sep = isset($optionsArray['thousands_sep']) ? $optionsArray['thousands_sep'] : null;
$output = number_format($number, $decimals, $dec_point, $thousands_sep);
return $output;
:
[[+price:numberformat=`&decimals=2&dec_point=,&thousands_sep=.`]]
좋은 크리스티안은, 몇 분 시도 할 것이다 – Kevin