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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Template Questions /

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

Pass parameter


Go to End


3 Posts   1060 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.