From 76436c0029f5be153f805a1be03e17ea26309906 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Fri, 7 Nov 2008 07:33:43 +0000 Subject: Add automatic pagination. All you have to do is add pager ?> to your theme file and you get a well formed pager. Themes can customize this any way they want. A version that matches the mockup is provided in the default theme. --- core/libraries/MY_Pagination.php | 35 +++++++++++++++++++++++++++++++++++ core/libraries/Theme.php | 12 +++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 core/libraries/MY_Pagination.php (limited to 'core/libraries') diff --git a/core/libraries/MY_Pagination.php b/core/libraries/MY_Pagination.php new file mode 100644 index 00000000..394e7be7 --- /dev/null +++ b/core/libraries/MY_Pagination.php @@ -0,0 +1,35 @@ +auto_hide === TRUE AND $this->total_pages <= 1) { + return ""; + } + + if ($style === NULL) { + // Use default style + $style = $this->style; + } + + // Return rendered pagination view + return View::factory("pager.html", get_object_vars($this))->render(); + } +} diff --git a/core/libraries/Theme.php b/core/libraries/Theme.php index 101cbb42..0f195d08 100644 --- a/core/libraries/Theme.php +++ b/core/libraries/Theme.php @@ -38,8 +38,18 @@ class Theme_Core { return new $view_class($page_name); } + public function pager() { + $this->pagination = new Pagination(); + $this->pagination->initialize( + array('query_string' => 'page', + 'total_items' => $this->template->item->children_count(), + 'items_per_page' => $this->template->page_size, + 'style' => 'classic')); + return $this->pagination->render(); + } + public function blocks() { - /** @todo: this needs to be made data-driven */ + /** @todo: make this data driven */ $blocks = array( 'carousel' => carousel::block($this), 'tags' => tags::block($this), -- cgit v1.2.3