0
$root = AnimeCommentQuery::create()->findRoot(2);
$html = "<ul>{$root->getComment()}";

foreach ($root->getDescendants() as $post)
{
  $html .= '<li style="padding-left: '.$post->getLevel().' em;">';
  $html .= $post->getComment();
  $html .= ' by '.$post->getIbfMembersRelatedByInsertBy()->getName();
  $html .= "</li>";
}

$html .= "</ul>";
echo $html;

I want to paginate the posts but I am not able to do this by:

$root = AnimeCommentQuery::create()->findRoot(2)->paginate(2, 1);

OR

$root = AnimeCommentQuery::create()->paginate(2, 1)->findRoot(2);

Can it be done with standard Pagination from propel? And how?

vyegorov
  • 21,787
  • 7
  • 59
  • 73

1 Answers1

0

Don't know if this is too late....

First off, you can't use the paginate and find in the same query, they're both termination methods.

I think what you need is something like this:

$comments = AnimeCommentQuery::create()->inTree(2)->orderByBranch()->paginate(2,1);

Then foreach your way through that Collection.

Now you'll have to be a bit clever with when to close and open lists, checking current Level etc. And top and bottom of page 2+ will take a bit of consideration too. Good Luck!

The Nested Set API is worth studying further http://www.propelorm.org/behaviors/nested-set.html#complete_api, got a fair bit in.

Also consider using a ->joinWith() to get your getIbfMembersRelatedByInsertBy() prepopulated in the main query.

TimW
  • 51
  • 1
  • 2