Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Maybe Bug in Paginator

Hi,

I just want to list some items paginated. But items of the Page object are always empty but total-items shows the right count! Heres My Code:

        $movies = Movies::find(array(
                    "order" => "createdAt DESC"
                        )
        );

        $paginator = new Paginator(array(
            "data" => $movies,
            "limit" => 10,
            "page" => $numberPage
        ));

        $this->view->page = $paginator->getPaginate();

In the View i just got:

    object(stdClass)[85]
          public 'items' => 
            array (size=0)
              empty
          public 'next' => int 1
          public 'first' => int 1
          public 'before' => int 1
          public 'current' => int 0
          public 'last' => int 7
          public 'total_pages' => int 7
          public 'total_items' => int 63

I've done it similiar to the Docs but it don't works?

Thanks for help.



46.0k
Accepted
answer

You're on page zero, but it looks like the page numbers start at 1. Make sure $numberPage is always between 1 and total_pages.

It's soled! Pagenum must bi bigger then 0 !