Jump to:

22979 Posts in 11815 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Operations on variables

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

Page: 1 2
Go to End
Author Topic: 1331 Views
  • BlueO
    Avatar
    Community Member
    52 Posts

    Re: Operations on variables Link to this post

    cool thanks!

    b

  • badjedi
    Avatar
    Community Member
    25 Posts

    Re: Operations on variables Link to this post

    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!

  • martimiz
    Avatar
    Forum Moderator
    1037 Posts

    Re: Operations on variables Link to this post

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

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

  • badjedi
    Avatar
    Community Member
    25 Posts

    Re: Operations on variables Link to this post

    Thanks, that worked!

    1331 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.