php的话.现在结合数据库.可以写成非递归的无限级了。请google..

解决方案 »

  1.   

    两层的话参照手册的例子:例 7-5. foreach 键的演示 {* The key contains the key for each looped valueassignment looks like this:$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
     array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
    *}
    {* 键就是数组的下标,请参看关于数组的解释 *}{foreach name=outer item=contact from=$contacts}
     {foreach key=key item=item from=$contact}
     {$key}: {$item}<br>
     {/foreach}
    {/foreach}OUTPUT:phone: 1<br>
    fax: 2<br>
    cell: 3<br>
    phone: 555-4444<br>
    fax: 555-3333<br>
    cell: 760-1234<br>
     
      

  2.   

    或者用:
    Example 7-16. section loop variable
    例 7-16.loop 变量演示 {* 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}
    OUTPUT:id: 1000<br>
    name: John Smith<br>
    address: 253 N 45th<br>
    <p>
    id: 1001<br>
    name: Jack Jones<br>
    address: 417 Mulberry ln<br>
    <p>
    id: 1002<br>
    name: Jane Munson<br>
    address: 5605 apple st<br>
    <p>
     
      

  3.   

    两层我也想过.可以弄出来.  但是 是无限级.  该怎么弄呢?我用了递归.  把部份HTML放进了PHP中. 但是也做不出来. 刚开始学. 好多都不懂.  看这里  
    http://topic.csdn.net/u/20080320/12/3cecdf55-0324-4e56-bd99-fc1eef44d0a9.htmlPS:  失去了用SMARTY的意义了....
      

  4.   

    我也遇到 你相同的问题。
    后来想了想:
    如果你还想用smarty 输出的话, 就在php中将树形结构的数据,输出成二维数组结构。然后传到smarty里面进行输出。
    因为不管你数据是如何存的、如何做的无限极,在界面上显示时必定是二维的结构。