Re: printing tree structures with smarty
| From: | Monte Ohrt | Date: | Wed, 02 Jan 2002 20:07:16 +0000 |
| Subject: | Re: printing tree structures with smarty | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2475@lists.php.net to get a copy of this message | ||
What I'm proposing is not to complicate the template with
recursion/relation logic. The template should only care about the
displaying of the data, not its relation in a tree.
So, think about how you want to display the data, maybe something like
this:
item1
item1.1
item1.2
item2
item2.1
item2.1.1
item2.1.2
item2.2
item2.2.1
item3
So the template engine basically needs to know three things about each
item: the order, the depth, and the content.
The order is easy, you just assign the items in the order you want them
displayed, then when you go through a section loop it will already be in
the correct order. Then you use the item depth to determine how far over
the current item is indented, and the item content is what is printed.
If you want to make it work with ordered lists, you might want to pass
another piece of information like when to open/close your tags, but you
get the idea.
Monte
Manuel Holtgrewe wrote:
>
> Monte Ohrt wrote:
>
> > That wouldn't be the function of the template engine would it?
>
> Okay...
>
> > Loop through your values when you assign them, and also assign the info
> > the template needs to display them like the current depth, etc.
>
> Sorry, I have absolutely no idea what you mean by that. Could you give
> me an example or an URL with examples, please ?
>
> Manuel
> --
> what privilege do we have under the sun,
> that gives us the right to the throne ?
> In Flames - "Coerced Coexistence"
>
> ---
> You are currently subscribed to smarty as: monte@ispi.net
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/
--
Monte Ohrt <monte@ispi.net>
http://www.ispi.net/