Re: [SMARTY] Working with arrays recursively
Ken Snyder <[email protected]> Fri, 31 Aug 2007 21:32:47 -0600
| Newsgroups | gmane.comp.php.smarty.general |
|---|---|
| Message-ID | <[email protected]> |
--------------010303090705040302000309
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
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 {include} 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}
--------------010303090705040302000309--