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

send three attributes to a function


Go to End


4 Posts   1094 Views

Avatar
DeklinKelly

Community Member, 197 Posts

21 May 2009 at 8:11am

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);
	}
}

Avatar
Willr

Forum Moderator, 5523 Posts

21 May 2009 at 2:56pm

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

Avatar
Willr

Forum Moderator, 5523 Posts

21 May 2009 at 2:56pm

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

Avatar
DeklinKelly

Community Member, 197 Posts

21 May 2009 at 9:16pm

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

               $xyz(1?2?3)

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