update - something like that to gather data:
sub get_blogs { my ($self, $c, $page) = @_; my $blogs; foreach $blog ( $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) { push @$blogs, get_replies($c, $blog, $page); } $blogs; } sub get_replies { my ($c, $blog, $page) = @_; my $replies; my $ret; my $replies = $c->model('YourSpaceDB::Blog')->search( { blog_is_hidden => 0, blog_is_reply => 1, blog_is_draft => 0, blog_is_reply_to => $blog->blog_id, }, { rows => 5, page => $page, order_by => 'blog_date DESC', } ); return [ $blog, 0, undef ] unless $replies; foreach my $reply (@$replies) { push @$ret, get_replies($c, $reply, $page); } [ $blog, scalar (@$replies), $ret ]; }
As I don't know anything about your data model, this is just a guess. The data structure would look like
$blogs = [ # blog list [ # first blog blog, 2, [ # replies structure [ # first reply reply, 0, undef, # no replies ], [ # second reply reply, 1, [ # replies structure [ # first reply reply, 0, undef, # no replies ] ] ], ], ], # end of first blog [ # second blog ... ], ]; # end of blog list
Roughly. The above might be buggy :-)
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: message board thread quandary
by shmem
in thread message board thread quandary
by stonecolddevin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |