stonecolddevin has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
I'm attempting to put together a threaded message board system where users can reply to everything posted, much like Perlmonks. I'm using Catalyst and FastCGI and so far so good.
However, I can't seem to figure out how to retrieve "replies to replies" so to speak. I can get replies to original threads, but I can't visualize what needs to be done as far as nested loops, etc. involved in retrieving the reply follow ups.
For visual effect, it would be nice to have something look like this (HTML notwithstanding):
etc., etc.
The relevant (perl) code:
sub default : Private { my ( $self, $c, $page ) = @_; my $blogs =[ $c->model('YourSpaceDB::Blog')->search( { blog_is_hidden => 0, blog_is_reply => 0, blog_is_draft => 0, }, { rows => 5, page => $page, order_by => 'blog_date DESC' } )->all ]; my $replies; push @$replies, { blog_id => $c->model('YourSpaceDB::Blog')->search( { blog_is_r +eply_to => $_->blog_id } )->count } for @$blogs ; $c->stash->{new_blogs} = $blogs; $c->stash->{replies} = $replies; $c->stash->{template} = 'index.tt2'; $c->log->debug(dump($replies)); }
The Template::Toolkit code:
[% # Reply stuffs -%] [% reply_count = []; reply_count.push(reply.blog_id) FOREACH reply IN replies %] <table> <tr> <a href="[% Catalyst.uri_for('/blog/reply/')_ blog.blog_id %]">< +h2>[% blog.blog_title %]</h2></a> <p>by <a href="[% Catalyst.uri_for('/users/view/')_ blog.blog_au +thor %]">[% blog.blog_author %]</a> on <em>[% blog.blog_date %]</em> +, is a reply: [% blog.blog_is_reply %], is a draft: is a draft: [% bl +og.blog_is_draft %]</p> [% FILTER html_para %] [% blog.blog_text %] [% END %] <small> tags: [% FOREACH tag IN blog.blog_tags.split(',') %] <a href="[% Catalyst.uri_for('/blog/do_search')_'?q='_ tag %]"> +[% tag %]</a> , [% END %] </small> </tr> </table>
Enlighten me monks. My brain has exhausted it's pool of knowledge in this matter.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: message board thread quandary
by shmem (Chancellor) on Sep 02, 2007 at 07:16 UTC | |
|
Re: message board thread quandary
by clinton (Priest) on Sep 02, 2007 at 09:50 UTC | |
by shmem (Chancellor) on Sep 02, 2007 at 15:02 UTC | |
by clinton (Priest) on Sep 02, 2007 at 15:20 UTC | |
by shmem (Chancellor) on Sep 02, 2007 at 15:41 UTC | |
by clinton (Priest) on Sep 02, 2007 at 15:48 UTC | |
|
Re: message board thread quandary
by GrandFather (Saint) on Sep 02, 2007 at 10:28 UTC | |
|
Re: message board thread quandary
by stonecolddevin (Parson) on Sep 02, 2007 at 16:25 UTC | |
by GrandFather (Saint) on Sep 02, 2007 at 20:53 UTC | |
|
Re: message board thread quandary
by Your Mother (Archbishop) on Sep 03, 2007 at 03:38 UTC | |
by stonecolddevin (Parson) on Sep 07, 2007 at 02:47 UTC | |
by Your Mother (Archbishop) on Sep 07, 2007 at 04:58 UTC | |
by stonecolddevin (Parson) on Sep 07, 2007 at 05:04 UTC | |
by Your Mother (Archbishop) on Sep 08, 2007 at 08:42 UTC | |
| |
|
Re: message board thread quandary
by stonecolddevin (Parson) on Sep 07, 2007 at 04:37 UTC |