Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates RE:将变量参数插入Silverstripe模板';s函数?_Templates_Silverstripe - Fatal编程技术网

Templates RE:将变量参数插入Silverstripe模板';s函数?

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) 页面模板:

我试图将一个变量传递给模板控制函数。 上述答案是否仍然适用于SS3?还是现在有更好的方法

谢谢,
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
(请参阅)