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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Operations on variables


Go to End


12 Posts   2390 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, 1391 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