smarttemplate里面assign变量值给变量,你看你那个参数能做变量么?
因为RESULT:id=22不是合格的变量名称,我觉得应该是不可以的。
要不然你看看解析后的生成的tmp目录里面的文件。

解决方案 »

  1.   

    1、不可以,因为smarttemplate的模板变量只允许是字母数字下划线。所以RESULT:id=22不会被替换
    2、你的 {RESULT:id=22} 倒很想一个模板函数,如果你是这样的话应该写做
    {RESULT:"22"}
    另外定义函数smarttemplate_extensions/smarttemplate_extension_result.php
    <?php
    function smarttemplate_extension_result($id) {
    ....
    }
    ?>
    而无须其他操作如果参数id是变量则写做
    {RESULT:id}
    用assign("id",22)赋值即可
      

  2.   

    最近我也在看smarttemplate
    smarttemplate_extensions/smarttemplate_extension_text.php
    function smarttemplate_extension_text ( $name, $key,$value )
    {  
    return "<input name=\"".$name."[".$key."]\" type=\"text\" value=\"".$value."\" size=\"12\" maxlength=\"50\">";
    }
    不知怎么输出结果不对
      

  3.   

    谢谢唠叨等大大...我试了唠叨的第二种方法。不是太合意。因为{RESULT:"22"}得到了一个最终结果,而我要考虑得出的结果能够用assign再处理。我尝试建立一个新的模板文件result.html用来assign{RESULT:"22"}中得到的结果,在smarttemplate_extension_result($id)函数中new SmartTemplate("result.html");如下:
    function smarttemplate_extension_result ( $id )
    {
    $array = array();
    $array['a'] = getDetail($id);
    $result= new SmartTemplate("result".EXT);
    $result->assign($array);
    echo $result->result();
    //echo $indexcategory->result();
    }不能得到执行。