Re: [SMARTY] evaluate data recursive
| From: | messju mohr | Date: | Sat, 31 Jan 2004 14:49:55 +0000 |
| Subject: | Re: [SMARTY] evaluate data recursive | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-10904@lists.php.net to get a copy of this message | ||
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}
On Fri, Jan 30, 2004 at 06:15:40PM +0100, Patrick Pletscher wrote:
> Hi,
>
> I have created a PHP script which creates a tree out of an XML file
> which represents the navigation of my website.
>
> Here the datastructre:
>
> class Node {
> var $name;
> var $link;
> var $id;
> var $childs = array();
> }
>
> I'd like now to show this navigation in the smarty style (of course I
> could do a simple recursive echo in my PHP script), but I wanna do it
> nicely. But how do so? I search a way to handle recursive datastructes
> in the way of {foreach ...} {/foreach}...
>
> Do I have to make a plugin or is there an easy solution for this? How do
> you make similar things in your projects?
>
> Thanks a lot in advance, sincerly
>
> Patrick
>
> --
> Smarty General Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php