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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   3357 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