List Info

Thread: Re: Working with arrays recursively




Re: Working with arrays recursively
user name
2007-08-31 22:32:47
Christoph Boget wrote:
>> To recurse, you must include a template that
includes itself to 
>> trek deeper into the array.
>>     
>
> Do you have an example?  How do you keep the variables
from overwriting
> one another?
>
> thnx,
> Christoph
>   
parameters can be assigned to the include file using
 to avoid 
overwriting--example below. - ken


main.tpl:

{include file="recurse.tpl" parents=$tree
level=0}


recurse.tpl

{foreach from=$parents item=child}
  {$child.name}
  {if $child.children}
    {include file="recurse.tpl"
parents=$child.children level=$level+1}
  {/if}
{/if}
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )