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();

Helpers\Pagination的更多相关文章

  1. ASP.NET Core 中文文档 第四章 MVC(3.6.1 )Tag Helpers 介绍

    原文:Introduction to Tag Helpers 作者:Rick Anderson 翻译:刘浩杨 校对:高嵩(Jack) 什么是 Tag Helpers? Tag Helpers 提供了什 ...

  2. ASP.NET Core 中文文档 第四章 MVC(3.6.2 )自定义标签辅助类(Tag Helpers)

    原文:Authoring Tag Helpers 作者:Rick Anderson 翻译:张海龙(jiechen) 校对:许登洋(Seay) 示例代码查看与下载 从 Tag Helper 讲起 本篇教 ...

  3. [asp.net core]定义Tag Helpers

    原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/authoring Getting started wi ...

  4. [asp.net core] Tag Helpers 简介(转)

    原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/intro What are Tag Helpers? ...

  5. pagination 分页

    <!DOCTYPE html> <html> <head> <title>pagination</title> <style type ...

  6. salesforce 零基础学习(四十九)自定义列表分页之使用Pagination实现分页效果 ※※※

    上篇内容为Pagination基类的封装,此篇接上篇内容描述如何调用Pagination基类. 首先先创建一个sObject,起名Company info,此object字段信息如下: 为了国际化考虑 ...

  7. salesforce 零基础学习(四十八)自定义列表分页之Pagination基类封装 ※※※

    我们知道,salesforce中系统标准列表页面提供了相应的分页功能,如果要使用其分页功能,可以访问http://www.cnblogs.com/zero-zyq/p/5343287.html查看相关 ...

  8. knockoutjs+ jquery pagination+asp.net web Api 实现无刷新列表页

    Knockoutjs 是一个微软前雇员开发的前端MVVM JS框架, 具体信息参考官网 http://knockoutjs.com/ Web API数据准备: 偷个懒数据结构和数据copy自官网实例  ...

  9. Handlebars块级Helpers

    1.Handlebars简单介绍: Handlebars是JavaScript一个语义模板库,通过对view和data的分离来快速构建Web模板.它采用"Logic-less templat ...

随机推荐

  1. 2016年VR&AR有市场吗?

    新霸哥发现了近期虚拟现实(VR)和增强现实(AR)非常火,已经成为了科技产业中最具前景的技术之一.其实说起这两项技术的应用,人们最容易把它与电子游戏联系在一起,那么在2016年VR&AR有市场 ...

  2. Java学习笔记(3)

    “当你定义出一组类的父型时,你可以用子型的任何类来填补任何需要或期待父型的位置” “运用多态时,引用类型可以是实际对象类型的父类”Animal myDog = new Dog(); 三种方法可以防止某 ...

  3. 《Java数据结构与算法》笔记-CH3简单排序

    class ArrayBub { private long[] arr; private int nElement; public ArrayBub(int size) { arr = new lon ...

  4. jar,war,ear区别及java基础杂七八

    jar,war,earqu区别 这三种文件都可以看作是java的压缩格式,其实质是实现了不同的封装: jar--封装类war--封装web站点ear--封装ejb.它们的关系具体为:jar:      ...

  5. Could not bind factory to JNDI

    将hibernate.cfg.xml中 <session-factory name="SessionFactory">的name属性去掉即可

  6. angular的注入实现

    angular需要对用户的传入函数进行静态分析,抽取当中的依赖,才能工作.因此用户的函数,包括控制器函数,工厂函数,服务函数与$watch回调都只是一个模板,用于取toString,真正运行的是编译后 ...

  7. 【转】从零开始,让你的框架支持CocoaPods

    首先概括一个大概的步骤: 代码上传到Github 创建podspec文件 在Github上创建release版本 注册CocoaPods账号 上传代码到CocoaPods 检验是否上传成功 更新框架版 ...

  8. Jvm基础(1)-Java运行时数据区

    最近在看<深入理解Java虚拟机>,里面讲到了Java运行时数据区,这是Jvm基本知识,把读书笔记记录在此.这些知识属于常识,都能查到的,如果我有理解不对的地方,还请指出. 首先把图贴上来 ...

  9. Spring入门(7)-自动检测Bean

    Spring入门(7)-自动检测Bean 本文介绍如何自动检测Bean. 0. 目录 使用component-scan自动扫描 为自动检测标注Bean 1. 使用component-scan自动扫描 ...

  10. iomanip.h

    http://baike.baidu.com/link?url=zuNLgcUVylhUYYefyV13F38NChIMx8nnCEWV5zkkTQMrrSdKPxUERZuydSHtp6sXukWv ...