Re: Hrm... stumped.
| From: | Jason Alexander | Date: | Tue, 13 Mar 2001 12:43:32 +0000 |
| Subject: | Re: Hrm... stumped. | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-384@lists.php.net to get a copy of this message | ||
Well, as usual, I coded in my sleep all night. What a restless night.
Anyways, the only way I could think was to have two seperate queries: one
query to pull all parent threads (where parent_id = 0), and all child
threads (where parent_id <> 0) and assign those to seperate variables within
the template.
Then, nest the sections something like:
{section name=parent_thread_loop loop=$parent_threads}
{section name=child_thread_loop loop=$child_threads}
{if $child_thread_loop/child_threads.parent_id ==
$parent_thread_loop/parent_threads.thread_id}
+ {$child_thread_loop/child_threads.thread_subject}
{/if}
{/section}
{/section}
Unfortunately, that means you have to itterate through the all of the child
threads for every parent ID. Which, in my case, works because I'm actually
pulling back a much smaller subset of data based on another ID not given
here.
-Jason
----- Original Message -----
From: "Alexander, Jason" <jalexander@aivia.net>
To: <smarty@lists.ispi.net>
Sent: Monday, March 12, 2001 7:48 PM
Subject: [smarty] Hrm... stumped.
> Hey all,
>
>
> I've got myself stumped here, and I wanted to see if anyone else can help
me
> out, perhaps. I'm attempting to write a hierarchical explorer-like view
with
> Smarty, and I'm having some issues.
>
> Given the following dataset:
>
> ID SUBJECT PARENT_ID
> ----------------------------------------------------------
> 1 Test1 0
> 2 Test2 1
> 3 Test3 2
> 4 Test4 0
> 5 Test5 4
> 6 Test6 4
>
>
> I'm wanting to create something like:
>
> + Test1
> + Test2
> + Test3
> + Test4
> + Test5
> + Test6
>
>
> Normally, I can handle this recursive by first grabbing the parent items,
> and then recursing down the childs, query for it's childs along the way.
> But, with Smarty I've happened across an interesting predicament, because
> (if I'm correct) I need to be able to preload a datastructure in a
> manageable format that I'm able to script out the layout in the template.
>
> I appreciate the help!
>
>
> TIA,
> -Jason
>
>
> ---
> You are currently subscribed to smarty as: j-l-alexander@home.com
> To unsubscribe send a blank email to $subst('Email.Unsub')
> Visit Smarty's homepage at
> http://www.phpinsider.com/php/code/Smarty/