Jump to:

23355 Posts in 17734 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » send three attributes to a function

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
Go to End
Author Topic: 695 Views
  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    send three attributes to a function Link to this post

    How can I send three attributes to a function?

    Here is my template:

    $customfunction(hello,5,50)

    Here is my code

    class TestPage_Controller extends Page_Controller {

       function customfunction ($attr1, $attr2, $attr3) {
        return ($attr1 . $attr2 . $attr3);
       }
    }

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: send three attributes to a function Link to this post

    Currently you cannot pass multiple variables through. I believe there is a patch sitting in open.silverstripe.com which will enable this. You will have to work around it I guess by going function MyMethod($values) and in the template MyMethod(hello 0 10) then spilting the string on the ' '? maybe if you can't have spaces you have to use _'s? hmmmm

  • Willr
    Avatar
    Forum Moderator
    5482 Posts

    Re: send three attributes to a function Link to this post

    Currently you cannot pass multiple variables through. I believe there is a patch sitting in open.silverstripe.com which will enable this. You will have to work around it I guess by going function MyMethod($values) and in the template MyMethod(hello 0 10) then spilting the string on the ' '? maybe if you can't have spaces you have to use _'s? hmmmm

  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Re: send three attributes to a function Link to this post

    Thanks for pointing me in the right direction. This works:

    $xyz(1?2?3)

       function zxy ($vals) {
          list($val1,$val2,$val3) = explode("?", $vals);
       }

    695 Views
Page: 1
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.