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


Go to End
Reply


12 Posts   1550 Views

Avatar
BlueO

Community Member, 52 Posts

2 November 2010 at 7:50pm

cool thanks!

b

Avatar
badjedi

Community Member, 25 Posts

31 January 2012 at 2:04pm

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

Forum Moderator, 1106 Posts

1 February 2012 at 6:03am

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

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

Avatar
badjedi

Community Member, 25 Posts

5 February 2012 at 6:55pm

Thanks, that worked!

Go to Top