Re: [SMARTY] Working with arrays recursively
| From: | Ken Snyder | Date: | Sat, 01 Sep 2007 03:32:47 +0000 |
| Subject: | Re: [SMARTY] Working with arrays recursively | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-13760@lists.php.net to get a copy of this message | ||
Christoph Boget wrote:
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}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