dana
dana

Reputation: 5208

Kohana 3.0 paginator does not paginate

i have a problem with the kohana pagination. i have made a method for paginating elements from the database, (let's say 3 on a page), but, (though the pagination links are there), the pagination is not actually done, meaning i always get listed all the elements of the query. the code i am using:

  1. in a helper:

     public function come_paginate_users(){
     $count = Model::factory('user')->count_all(); //echo $count; exit();
    
    $pagination = Pagination::factory(array(
    'total_items'    => $count,
    'items_per_page' => 2,
    'auto_hide'      => TRUE,
    
     ));
    
    $results = Model::factory('user')->order_by('user_id','ASC')->limit($pagination-                     >items_per_page)->offset($pagination->offset)->find_all();//->execute();
    
     $page_links = $pagination->render();
     return $pagination;
         }
    

in the controller:

                $pagination = @helper_utilities::come_paginate_users();
                $this->view->pagination = $pagination;

and in the view:

               <? echo 'Classic style: '.$pagination;?>

but... the pagination is not working. any idea why? thank you!

Upvotes: 0

Views: 337

Answers (2)

Aren_SH
Aren_SH

Reputation: 61

Actually, You need to return $page_links (wich is rendered html) and $result instead of $pagination object in your come_paginate_users() method

Upvotes: 1

delphist
delphist

Reputation: 4539

Maybe total_items < items_per_page and auto_hide hides the pagination? Try to set auto_hide to FALSE

Upvotes: 0

Related Questions