Re: Hrm... stumped.
| From: | Jason Alexander | Date: | Tue, 13 Mar 2001 23:12:31 +0000 |
| Subject: | Re: Hrm... stumped. | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-391@lists.php.net to get a copy of this message | ||
Actually, that's great... that would work much better!
Thanks for the help!
-Jason
----- Original Message -----
From: "Monte Ohrt" <monte@ispi.net>
To: "Jason Alexander" <j-l-alexander@home.com>
Cc: <smarty@lists.ispi.net>
Sent: Tuesday, March 13, 2001 8:44 AM
Subject: [smarty] Re: Hrm... stumped.
> I might be off base here, but I'll give it a shot :-)
>
> Couldn't you do your recursion up front in PHP, then pass depth
> coordinates with each record to the template engine for display in a
> table or bulleted list? The template engine shouldn't care about
> parent/child relationships of the records, it should only care about
> where to place them visually. Once you know the depth (position from
> left to right) for each record, loop through the records and write a
> template function that computes and displays the row output.
>
>
>
> Jason Alexander wrote:
> >
> > 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/
> >
> > ---
> > 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/
>
> ---
> 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/