Helpers\Pagination

Helpers\Pagination

Break recordset into a series of pages.

First create a new instance of the class pass in the number of items per page and the instance identifier, this is used for the GET parameter such as ?p=2

The setTotal method expects the total number of records, either set this or pass in a call to a model that will return records then count them on return.

The method used to get the records will need a getLimit passed to it, this will then return the set number of records for that page.

Lastly a method called page_links will return the page links.

The model that uses the limit will need to expect the limit:

public function getContacts($limit)
{
    return $this->db->select(‘
        SELECT
        *,
        (SELECT count(id) FROM ‘.PREFIX.‘contacts) as total
     FROM ‘.PREFIX.‘contacts ‘.$limit);
}

Pagination concept

//create a new object
$pages = new Paginator(‘1‘, ‘p‘);

//calling a method to get the records with the limit set (model would be the var holding the model data)
$data[‘records‘] = $this->model->getContacts($pages->getLimit());

//set the total records, calling a method to get the number of records from a model
$pages->setTotal($data[‘records‘][0]->total);

//create the nav menu
$data[‘pageLinks‘] = $pages->pageLinks();

Usage example:

$pages = new Paginator(‘50‘,‘p‘);
$data[‘records‘] = $this->model->getContacts($pages->getLimit());
$pages->setTotal($data[‘records‘][0]->total);
$data[‘pageLinks‘] = $pages->pageLinks();
时间: 2024-11-12 15:41:03

Helpers\Pagination的相关文章

GHOST CMS - Utility Helpers公用事业帮手

Utility Helpers Utility helpers are used to perform minor, optional tasks. Use this reference list to discover what each handlebars helper can do when building a custom Ghost theme. Available utility helpers asset ghost_head/foot body_class post_clas

angular4 中自定义pagination组件

你用Angular 吗? 一.介绍 一个基于angular4 开发的可以分页的组件.组件的好处就是可以复用,复用.....作为一个前端码农,开始的分页功能实现是我用jquery写的,其他同事用的时候都要将我的代码拷贝过去,于是我被鄙视了.为了不继续被鄙视就开始了尝试. 二.基本功能 1.根据规定的每页数据条数,分页显示数据 2. 上下页操作数据 直接上界面图可能清晰点: 项目截图 根据图片进行讲解下: 根据你总数据条数:totalNum; 每页显示条数:pageSize,通过组件会自动给你分页显

第二百零九节,jQuery EasyUI,Pagination(分页)组件

jQuery EasyUI,Pagination(分页)组件 学习要点: 1.加载方式 2.属性列表 3.事件列表 4.方法列表 本节课重点了解 EasyUI 中 Pagination(分页)组件的使用方法,这个组件依赖于 LinkButton(按钮)组件.

pagination分页问题

  一,真心话(可能是我蠢0.0): 20天easyui学习后,这里想整理下一个困扰我很久的分页问题,在附代码前,说下为什么会困扰我那么久.easyui很重要的一点就是控件初始化问题(最好统一,要么都在Js里,要么都在页面里),这在分页问题里特别重要,当你想要用datagrid自带的pagination属性时,千万不要在页面中初始化,因为那样当你在js里获取后台传来的表格数据时,不管你怎么选择pagesize和pagenumber时,表格都不会刷新的.下面就分享下前后台代码.写的可能不是很好吧,

mvc中使用Pagination,对其进行再封装

对其进行再次封装: (function($) { $["fn"]["easyPaging"] = function(o) { if (!o.pageSelect ||!$["fn"]["pagination"]) { return this; } var num = o.num || 50; var opts = { "items_per_page": 10, "num_display_entri

无刷新分页 jquery.pagination.js

1.使用插件为 jquery.pagination.js ,如果没有这个js文件的话,我可以给发个. 首先引用 jquery.pagination.js (分页js),跟pagination.css(分页样式css). 点击获取查看这两个文件 2.页面js代码为 <script type="text/javascript"> var pageIndex = 0; //页面索引初始值 var pageSize = 15; //每页显示条数初始化,修改显示条数,修改这里即可 $

ASP.NET MVC WebGrid &ndash; Performing true AJAX pagination and sorting 【转】

ASP.NET MVC WebGrid – Performing true AJAX pagination and sorting FEBRUARY 27, 2012 14 COMMENTS WebGrid is a very powerful HTML helper component introduced with ASP.NET MVC 3 and ASP.NET Web Pages. Despite all its cool features, it is troublesome to

AngularJs的UI组件ui-Bootstrap分享(五)——Pager和Pagination

ui-bootstrap中有两个分页控件,一个是轻量级的Pager,只有上一页和下一页的功能,另一个是功能完整的Pagination,除了上一页和下一页,还可以选择首页和最后页,并且支持多种页数的显示方式. 这是Pager的例子: 1 <!DOCTYPE html> 2 <html ng-app="ui.bootstrap.demo" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4

BootStrap pagination

Default paginationSimple pagination inspired by Rdio, great for apps and search results. The large block is hard to miss, easily scalable, and provides large click areas. <nav aria-label="Page navigation"> <ul class="pagination&quo