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.

meh.

In reply to message board thread quandary by stonecolddevin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.