Jump to:

3439 Posts in 1028 Topics by 869 members

Template Questions

SilverStripe Forums » Template Questions » Pass parameter

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

Page: 1
Go to End
Author Topic: 449 Views
  • Graphicator
    Avatar
    Community Member
    62 Posts

    Pass parameter Link to this post

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

  • n0ne
    Avatar
    Community Member
    18 Posts

    Re: Pass parameter Link to this post

    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.

  • Graphicator
    Avatar
    Community Member
    62 Posts

    Re: Pass parameter Link to this post

    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.

    449 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.