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.

Template Questions /

Pass parameter


Reply


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