Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Operations on variables


Reply

12 Posts   1489 Views

Avatar
BlueO

2 November 2010 at 7:50pm Community Member, 52 Posts

cool thanks!

b

Avatar
badjedi

31 January 2012 at 2:04pm Community Member, 25 Posts

How would you add a variable defined in a customsite config to this?

For example if you set a exchange rate in a CustomSiteConfig, then wanted to use in this where the $num is?

in Page.php :

function eaPayment() {
$num = 4; //replace this value with a variable from customsite config UK below
$total = $this->Total;
$ea = $total/$num;
return $ea;
}

in CustomSiteConfig.php :

class CustomSiteConfig extends DataObjectDecorator {

function extraStatics() {
return array(
'db' => array(

class CustomSiteConfig extends DataObjectDecorator {

function extraStatics() {
return array(
'db' => array(
'Uk' => 'Decimal'
)
);
}

Thanks in advance!

Avatar
martimiz

1 February 2012 at 6:03am Forum Moderator, 1091 Posts

From the Page_Controller you can access the Uk value by doing:

$num = $this->SiteConfig()->Uk;

Avatar
badjedi

5 February 2012 at 6:55pm Community Member, 25 Posts

Thanks, that worked!