This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
developers:templates:reference [2014/10/18 12:44] Jaco van Wyk |
developers:templates:reference [2014/10/18 12:49] Jaco van Wyk |
||
---|---|---|---|
Line 35: | Line 35: | ||
Some variables hold values that we might want to be formatted according to a set of rules. For instance if we had $date with today’s date in it, putting it in the template would write “2011-01-14 14:03:35″. While sometimes that’s what we want, sometimes you would want to write it as “January 14th”, and sometimes as “14 Jan, 2:03pm”. In order to allow for all of these options we have a formatting option for variables. | Some variables hold values that we might want to be formatted according to a set of rules. For instance if we had $date with today’s date in it, putting it in the template would write “2011-01-14 14:03:35″. While sometimes that’s what we want, sometimes you would want to write it as “January 14th”, and sometimes as “14 Jan, 2:03pm”. In order to allow for all of these options we have a formatting option for variables. | ||
- | In order to format a variable, simply put parenthesis straight after the variable without any spaces. Each variable is formatted differently, according to its type. A date variable is formatted according to the PHP date function so “$date(F jS)” would write out “January 14th”. Most other variables are formatted according to printf formatting. | + | In order to format a variable, simply put parenthesis straight after the variable without any spaces. Each variable is formatted differently, according to its type. A date variable is formatted according to the [[http://php.net/manual/en/function.date.php|PHP date function]] so “$date(F jS)” would write out “January 14th”. Most other variables are formatted according to [[http://en.wikipedia.org/wiki/Printf#Format_placeholders|printf formatting]]. |
Some variables can even be formatted according to other variables. This is the case you would generally use with formatting according to currency. If you have the client credit of 14.65 in $credit you would simply call “$credit($client->currency)” which would then print out R14.65 if your client is using South African Rands :) . | Some variables can even be formatted according to other variables. This is the case you would generally use with formatting according to currency. If you have the client credit of 14.65 in $credit you would simply call “$credit($client->currency)” which would then print out R14.65 if your client is using South African Rands :) . |