Inserting a variable argument into a Silverstripe template's function?
I am trying to pass a variable to a template control function. Is the above answer still current for SS3? Or is there a better way of doing it now?
Thanks, Rob
Inserting a variable argument into a Silverstripe template's function?
I am trying to pass a variable to a template control function. Is the above answer still current for SS3? Or is there a better way of doing it now?
Thanks, Rob
在 silverstripe 3 中可以将动态值传递给模板中的函数调用。尝试以下操作:
页面类:
public function testfunc($myval) {
return 'value is '.$myval;
}
public function testval() {
return 'foobar';
}
页面模板:
$testfunc($testval)
这将按预期在您的模板中输出“foobar”。
请注意,该control
指令在 ss3 中已弃用,请使用loop
orwith
代替(请参阅http://doc.silverstripe.org/framework/en/reference/templates)