Last active
December 7, 2015 23:29
-
-
Save craigcooperxyz/84d089e8a9d8dfb08834 to your computer and use it in GitHub Desktop.
Kirby CMS British Pounds Sterling (GBP) Currency Field Method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// This field method for Kirby adds a method called GBP (Since extended to gbpsmall or gbplarge) | |
// Use it like this | |
// echo $page->price()->gbplarge() | |
// This example is intended for large figures such as £100,000 or £5,000, there are no decimal places | |
field::$methods['gbplarge'] = function($field) { | |
return '£' . number_format($field->value, 0, '.' , ',' ); | |
}; | |
// This example is intended for smaller figures such as £99.99 or £2.99, there are two decimal places | |
field::$methods['gbpsmall'] = function($field) { | |
return '£' . number_format($field->value, 2, '.' , ',' ); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment