Kohana 3.1 Pagination Links Issue
I have done the pagination in Kohana 3.1 using the following code in my controller page .How can I display the Pagination links in my view page ? Is this the correct way ??? or any issue with my code ?
public function action_imagelist()
{
$per_page =2;
$page_num = $this->request->param('page', 1);
$offset = ($page_num - 1) * $per_page;
$view =View::factory('image/imagelist')->bind('page_links',$page_links)->bind('results', $results)->bind('pagination', $pagination);
// Get the total count of records in the database
$userid = Auth::instance()->get_user()->pk();
$count=ORM::factory('user_image')->where('app_userid','=',$userid)->count_all();
// Create an instance of Pagination class and set values
$pagination = Pagination::factory(array(
'total_items' => $count,
'current_page' => array('source' => 'image/imagelist', 'key' => 'page'),
'items_per_page' => $per_page,
'offset' => $offset,
'view' => 'pagination/basic'
));
// Load specific results for current page
$results = DB::select()->from('user_images')
->where('app_userid','=',$userid)
->order_by('image_id','ASC')
->limit($pagination->items_p开发者_StackOverflower_page)
->offset($pagination->offset)->execute();
// print_r($results);
$page_links = $pagination;
$this->template->content=$view->render();
}
To display pagination, in your view print out $page_links
.
You should read how stuff is divided in MVC pattern!
精彩评论