in reply to Re^2: message board thread quandary
in thread message board thread quandary

Only because the posts are threaded too. It's not necessary to have another table otherwise (well, except for users and whatever you want attached). The comments are threaded in and of themselves. It just happens to be a blog package so they are also attached to a post. If it were for a forum, they'd be standalone in their table and any without a parent would be the first in a thread.

Replies are listed 'Best First'.
Re^4: message board thread quandary
by stonecolddevin (Parson) on Sep 07, 2007 at 05:04 UTC

    I'm a little confused then, perhaps you could help me out and explain how I set up a relationship within the post/blog table to retrieve the replies to replies correctly as you've done in your code. I don't quite grok how that is done.

    meh.

        After trying to grok what you gave me, I came up with this:

        Template code:

        [% FILTER html_para %] [% reply.blog_text %] [% END %] <small> tags: [% FOREACH tag IN reply.blog_tags.split(',') %] <a href="[% Catalyst.uri_for('/blog/do_search')_'?q='_ tag %]"> +[% tag %]</a> , [% END %] <p><a href="[% Catalyst.uri_for('/blog/reply/')_ reply.blog_id +%]">comment</a></p> </li> [% IF recurse %] <ul> [% FOREACH child_reply IN blog.replies -%] <li> <p>[% child_reply.blog_title %]</p> <p>[% child_reply.blog_text %]</p> </li> [% END %] </ul> [% END %] </ul> </small> </td> </tr> [% END %]

        Perl code:

        YourSpaceDB::Blog.pm stuff: ## Thanks to YourMother of Perlmonks __PACKAGE__->belongs_to('blog_parent' => __PACKAGE__); __PACKAGE__->has_many('replies' => __PACKAGE__, 'blog_parent', undef, { order_by => 'blog_date' } ); sub parents { my ( $self, @parents ) = @_; my $parent = $self->parent; return @parents unless $parent; push @parents, $parent; die "Endless lineage loop suspected!" if @parents > 100; $parent->parents(@parents); } #### reply page: sub reply : Local { my ($self, $c, $blog_id) = @_; # Set the TT template to use $c->stash->{blog} = $c->model('YourSpaceDB::Blog')->find($b +log_id); $c->stash->{replies} = [ $c->model('YourSpaceDB::Blog')->search( { blog_is_reply => 1, blog_parent => $blog_id, blog_is_draft => 0, } ) ]; $c->stash->{recurse} = 1; $c->stash->{template} = 'blog/reply.tt2'; }

        What I'm running into is it will show something that LOOKS like a reply under the first reply, so as to say the reply has a reply, but it'll have the same title/content/etc. The reply shows up when you click on the node that has the reply, but not before that.

        It looks something like this:

        original node -reply to original node --reply to reply, but with same title as reply to original node

        Thoughts?

        meh.