Templates RE:将变量参数插入Silverstripe模板';s函数?
我试图将一个变量传递给模板控制函数。 上述答案是否仍然适用于SS3?还是现在有更好的方法 谢谢,Templates RE:将变量参数插入Silverstripe模板';s函数?,templates,silverstripe,Templates,Silverstripe,我试图将一个变量传递给模板控制函数。 上述答案是否仍然适用于SS3?还是现在有更好的方法 谢谢, Rob在silverstripe 3中,可以将动态值传递给模板中的函数调用。 请尝试以下操作: 页面类: public function testfunc($myval) { return 'value is '.$myval; } public function testval() { return 'foobar'; } $testfunc($testval) 页面模板:
Rob在silverstripe 3中,可以将动态值传递给模板中的函数调用。 请尝试以下操作: 页面类:
public function testfunc($myval) {
return 'value is '.$myval;
}
public function testval() {
return 'foobar';
}
$testfunc($testval)
页面模板:
public function testfunc($myval) {
return 'value is '.$myval;
}
public function testval() {
return 'foobar';
}
$testfunc($testval)
这将按预期在模板中输出“foobar”
请注意,ss3中不推荐使用控制
指令,请改用循环
或with
(请参阅)