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

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.

Replies are listed 'Best First'.
Re^5: message board thread quandary
by Your Mother (Archbishop) on Sep 08, 2007 at 08:42 UTC

      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.