Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.3/master #6

Open
wants to merge 12 commits into
base: 3.2/develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 67 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,72 @@
Kohana 3.2 Pagination
Kohana 3.3 and 3.2 Pagination
---

This is pretty much hacked up to support Kohana 3.2 so there are a few things to note:
This is pretty much hacked up to support Kohana 3.3 and 3.2 so there are a few things to note:

- Request, Route and route parameters dependency injection added
- Current Request is used by default instead of the initial one ($_GET was used directly in < 3.2)
- URL::query() has been removed, Pagination::query() added instead (HMVC support)
- URL::query() has been removed, Pagination::query() added instead (HMVC support)
- Add feauture to limit links in rendered html template.

Usage Example
---

//first calc average count
$count = $count_sql->count_all();

//you can change items_per_page
$num = 10;
//you can configure routes and custom routes params
$pagination = Pagination::factory(array(
'total_items' => $count,
'items_per_page' => $num,
// 'current_page' => Request::current()->param("page"),
)
)
->route_params(array(
'directory' => Request::current()->directory(),
'controller' => Request::current()->controller(),
'action' => Request::current()->action(),
"id" => $date,
"id2" => $date2,
)
);

//now select from your DB using calculated offset
$logs = $logs_sql->order_by("id", "DESC")
->limit($pagination->items_per_page)
->offset($pagination->offset)
->group_by("id")
->find_all()->as_array();

//and finally set view variables
$this->content = View::factory("admin/log/asb/main.tpl")
->set("logs", $logs)
->set('pagination', $pagination);

Variable $pagination will automatically convert to rendered from tpl html.

In this version added some new config features!

Config Example:
---
return array(
// Application defaults
'default' => array(
// source: "query_string" or "route"
'current_page' => array('source' => 'query_string',
'key' => 'page'),
'total_items' => 0,
'items_per_page' => 10,
'view' => 'pagination/limited',
'auto_hide' => TRUE,
'first_page_in_url' => FALSE,

//NEW! Use limited template.
'max_left_pages' => 10,
'max_right_pages' => 10,
),
);

In pagination/view folder added limited tpl, witch can limit number of left and right
pages links by config variables.
Loading