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.
In reply to message board thread quandary by stonecolddevin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |