请问smarty_foreach函数在哪儿?
smarty.class.php中?找不到阿

解决方案 »

  1.   

    哦找到了,应该是这个吧:
    function _compile_foreach_start($tag_args)
    在Smarty_Compile.class.php中找到的。改写这个函数我会试试看的。但是没有别的变通的方法么?
      

  2.   

    第一个问题用section应该可以,手册上的例子:{* the loop variable only determines the number of times to loop.
       you can access any variable from the template within the section.
       This example assumes that $custid, $name and $address are all
       arrays containing the same number of values *}
    {section name=customer loop=$custid}
    id: {$custid[customer]}<br>
    name: {$name[customer]}<br>
    address: {$address[customer]}<br>
    <p>
    {/section}
      

  3.   

    第二个问题用total,一样手册上的例子,(但是似乎要配合section)total is used to display the number of iterations that this section will loop. This can be used inside or after the section. Example 7-30. section property total{section name=customer loop=$custid step=2}
    {$smarty.section.customer.index} id: {$custid[customer]}<br>
    {/section} There were {$smarty.section.customer.total} customers shown above. OUTPUT: 0 id: 1000<br>
    2 id: 1001<br>
    4 id: 1002<br> There were 3 customers shown above.