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.

Template Questions /

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

Pass parameter


Go to End


3 Posts   1630 Views

Avatar
Graphicator

Community Member, 62 Posts

18 September 2012 at 8:05pm

Edited: 18/09/2012 8:08pm

Why wouldn't this work?

*in page.ss

<div class=" show$Opt(Count) half$Opt(Half) clearfix">

*in page_controller of Page.php

 	public function getOpt($opt = 'Count'){
	switch($opt):
			case('Count'):
				  return foo;
				break;
			case('Half'):
				  return bar;
				break;
			endswitch;
}

Avatar
n0ne

Community Member, 18 Posts

20 September 2012 at 8:13am

Well I think that u should call for getOpt(...) instead of Opt, and the second thing is that u should a pass a string to a function.

Avatar
Graphicator

Community Member, 62 Posts

21 September 2012 at 7:41am

The reason I ask is that I've only seen numbers passed as parameters in all the Silverstripe examples. I will take the string approach and see if that makes the fix.