21285 Posts in 5732 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 556 Views |
-
Displaying Currency Nicely

31 August 2011 at 10:01pm Last edited: 31 August 2011 10:02pm
Hi there. I am using the currency object as one of the fields in an object on Silverstripe. However; whenever I display it in the temaple it has four digits after the decimal point. I just wondered if there is anyway of stopping it and it only showing two. Below is an example of the code:
<% control Courses %>
<tr>
<td class="first"><a href="{$Top.BaseHref}{$Top.URLSegment}/{$URLSegment}">$Title</a></td>
<td>$Duration</td>
<td class="highlight">{$PriceCurrency}{$PriceAmount}
</td>
<td class="last"><a class="date-link" href="/booking/course/{$ID}">Find Dates</a></td>
</tr>
<% end_control %><tr>
<td class="first"><a href="{Link Removed}">Fire Safety Course</a></td>
<td></td>
<td class="highlight">£0.0000</td>
<td class="last"><a class="date-link" href="/booking/course/2">Find Dates</a></td>
</tr>Hope someone can help.
Cheers,
Steve -
Re: Displaying Currency Nicely

31 August 2011 at 11:54pm
You could use $PriceCurrency.Nice in your template...
-
Re: Displaying Currency Nicely

2 September 2011 at 10:31pm
Thanks martimiz but it didn't work. It didn't show up anything if I did that.
Other options I've tried that didn't work are:
$PriceCurrency.Format
$PriceCurrency.Currency
$PriceCurrency.DecimalAnyone got any other suggestions?
Cheers,
Steve -
Re: Displaying Currency Nicely

2 September 2011 at 11:20pm
I figured it out! We we're nearly there with Nice. But it should of been attached to the object, not the string of it. So to get it to work I used:
$Price.Nice
And it worked
Cheers,
Steve -
Re: Displaying Currency Nicely

5 March 2012 at 9:10am
For anybody having problems getting currency symbols to display with .Nice - use the code for the symbol:
Currency::setCurrencySymbol('£');
| 556 Views | ||
|
Page:
1
|
Go to Top |


