Quote from: goldsky at Dec 27, 2009, 11:39 PM
Let’s say you have had a [*price*] TV already.
Then create a price ’snippet’:
<?php
$priceTV = $modx->getTemplateVarOutput("price");
$price = number_format($priceTV['price'], 2, ',', '.');
return $price;
?>
Test it:
Price: [*price*] //<-- TV
Price: [[price]] //<-- Snippet
Result:
Price: 65432984651.56
Price: 65.432.984.651,56
thank u! I changed the last period to a comma and its outputting the way i want it accept for the decimal/comma b4 the last 2 numbers.. there wont be cents displayed on the page.. just numbers like $100,000 or $10,000,000 so the last decimal/comma isnt needed.. lookin thru the php page tryin to find how to get it to work without that last part
edit: edit up changing the 2 to 0
<?php
$priceTV = $modx->getTemplateVarOutput("price");
$price = number_format($priceTV['price'], 2, ',', ',');
return $price;
?>
<?php
$priceTV = $modx->getTemplateVarOutput("price");
$price = number_format($priceTV['price'], 0, ',', ',');
return $price;
?>
would this be the correct way to do this?