01.09.10
Sample article Sample articleSample articleSample article
02:25:2009
Quick & Dirty pagination w/ Kohana (pagination helper)
Pagination is something that I require in 95% of every application that I probably develop, kohana has a pretty ok pagination library but implementing it over and over every single time I need to use it is something I really do not enjoying doing, so again in defiance of the Leader of Kohanatropolis here is a pagination helper I added to _theframework to make my life easier…
USAGE
$paginate = paginator::pages('page',200,5,'punbb'); //rende the pagination likks echo $paginate->render(). "\r\n"; //get the pagination offset echo $paginate->sql_offset();
The helper is Chainable so it allows you to attach core pagination functions such as the sql_offset function.
Class:- paginator.php
<?php defined('SYSPATH') or die('Access denied'); class paginator_Core{ /** * paginator_Core::pages() * @param mixed $uri // pass a string as uri_segment to <span> </span> * trigger former 'label' functionality * @param mixed $total_items // use db count query here of course * @param mixed $items_ppage // it may be handy to set defaults for * stuff like this in config/pagination.php * @param mixed $style // pick one from: classic (default), * digg, extended, punbb, or add your own! * @return */ public static function pages($uri,$total_items,$items_ppage,$style) { $pagination = new Pagination(array( 'uri_segment' => $uri, 'total_items' => $total_items, 'items_per_page' => $items_ppage, 'style' => $style )); return $pagination; } }
Related Posts:
Posted in:
Bookmarked On :
February 25th, 2009







Do you make wrappers for all the Kohana libraries?
If it means that I do not have to write the same line of code over and over YES