请问自定义函数和模板里如何设置、传递两个变量?

#1 gnuser

我在自定义函数里定义了(简化了):
function pagelist($thepage,$allpages){
    echo $thepage."
";
    echo $allpages;
}
function tpl_pagelist($p1,$p2){
    return pagelist($p1['thepage'],$p2['allpages']);
}
spAddViewFunction('page','tpl_pagelist');


然后在模板page.html中用如下输出:
<{page thepage=$pager.current_page allpages=$pager.total_page}>

如果提示错误Smarty Error: Syntax Error in template "E:\APMServ5.2.6\APMServ5.2.6\www\htdocs\sp/tpl\default/bbs/page.html" on line 1 "<{page thepage=$pager.current_page allpages=$pager.total_page)}>" - Unexpected ")", expected one of: "}>" , " "

请问有什么办法可以使用两个变量呢?谢谢

2011-06-14 13:43:06

#2 jake

看手册 http://speedphp.com/view-functions.html
另外,模板代码里面多了个括号,检查

2011-06-14 19:45:22

#3 anythink

function tpl_pagelist($p1,$p2){
    return pagelist($p1['thepage'],$p2['allpages']);
}
spAddViewFunction('page','tpl_pagelist');


这种传的不对



function tpl_pagelist($pragrm){

$p1 = $pragrm['p1'];
$p2 = $pragrm['p2'];

2011-06-14 22:48:59

#4 gnuser

感谢,我试试看。

2011-06-15 08:28:55