Re: [SMARTY] evaluate data recursive
| From: | Patrick Pletscher | Date: | Sat, 31 Jan 2004 15:12:32 +0000 |
| Subject: | Re: [SMARTY] evaluate data recursive | ||
| References: | 1 2 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10905@lists.php.net to get a copy of this message | ||
Hello,
> Hello,
>
> without any plugins or extensions the only way I know to do recursion
> inside the template is to recursively include a template. Something
> like:
>
> [menu.tpl]
> {$item->name}
> {foreach from=$item->childs item=child}
> {include file="menu.tpl" item=$child}
> {/foreach}
>
>
Thanks for your reply. I guess this would work quite well for my
purpose, except, that I should know how deep I am in the recursion for
putting spaces ( ) in front of the links.
Is there a plan to include a Smarty function which could look like this:
{recursive from=$variable item=new type=preorder|inorder|postorder
recursive_for=$variable->childs name=my_recursion}
{smarty.my_recursion.depth} {new->name}
{/recursive}
Because recursive datastructres are quite usefull in many areas of
computer science I think it would be a great feature if smarty could
include a function for handling them...
Or is such a plugin written easily, I didn't know that, because I never
had the need to write a smarty-plugin
Sincerly, Patrick