For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > August 2007 > Re: [SMARTY] Working with arrays recursively









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] Working with arrays recursively
Ken Snyder

2007-08-31, 11:40 pm

Christoph Boget wrote:
>
> 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}

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com