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();
Helpers\Pagination的更多相关文章
- ASP.NET Core 中文文档 第四章 MVC(3.6.1 )Tag Helpers 介绍
原文:Introduction to Tag Helpers 作者:Rick Anderson 翻译:刘浩杨 校对:高嵩(Jack) 什么是 Tag Helpers? Tag Helpers 提供了什 ...
- ASP.NET Core 中文文档 第四章 MVC(3.6.2 )自定义标签辅助类(Tag Helpers)
原文:Authoring Tag Helpers 作者:Rick Anderson 翻译:张海龙(jiechen) 校对:许登洋(Seay) 示例代码查看与下载 从 Tag Helper 讲起 本篇教 ...
- [asp.net core]定义Tag Helpers
原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/authoring Getting started wi ...
- [asp.net core] Tag Helpers 简介(转)
原文地址 https://docs.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/intro What are Tag Helpers? ...
- pagination 分页
<!DOCTYPE html> <html> <head> <title>pagination</title> <style type ...
- salesforce 零基础学习(四十九)自定义列表分页之使用Pagination实现分页效果 ※※※
上篇内容为Pagination基类的封装,此篇接上篇内容描述如何调用Pagination基类. 首先先创建一个sObject,起名Company info,此object字段信息如下: 为了国际化考虑 ...
- salesforce 零基础学习(四十八)自定义列表分页之Pagination基类封装 ※※※
我们知道,salesforce中系统标准列表页面提供了相应的分页功能,如果要使用其分页功能,可以访问http://www.cnblogs.com/zero-zyq/p/5343287.html查看相关 ...
- knockoutjs+ jquery pagination+asp.net web Api 实现无刷新列表页
Knockoutjs 是一个微软前雇员开发的前端MVVM JS框架, 具体信息参考官网 http://knockoutjs.com/ Web API数据准备: 偷个懒数据结构和数据copy自官网实例 ...
- Handlebars块级Helpers
1.Handlebars简单介绍: Handlebars是JavaScript一个语义模板库,通过对view和data的分离来快速构建Web模板.它采用"Logic-less templat ...
随机推荐
- Java Spring boot 系列目录
Spring boot 介绍 Spring boot 介绍 Spring boot 介绍 Spring boot 介绍 Spring boot 介绍 Spring boot 介绍 Spring boo ...
- android sensor传感器系统架构初探
http://blog.csdn.net/qianjin0703/article/details/5942579 http://blog.chinaunix.net/uid-28621021-id-3 ...
- [微软实习生2014]K-th string
很久之前的事情了,微软2014实习生的在线测试题,记录下来以备后用. 题目描述: Description Consider a string set that each of them consist ...
- 《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇04:碰撞检测》
4.碰撞检测 碰撞概述: 游戏世界里,游戏对象不能做出如同在真实世界里的物理运动效果.对于大部分游戏来说,都要为其添加物理系统,让其可以模拟真实世界发生的物理运动.但是在这个打飞机游戏Demo中,是用 ...
- NodeJS学习:爬虫小探补完计划
说明:本文在个人博客地址为edwardesire.com,欢迎前来品尝. 书接上回,我们需要修改程序以达到连续抓取40个页面的内容.也就是说我们需要输出每篇文章的标题.链接.第一条评论.评论用户和论坛 ...
- 如何学习java ee
来看看Sun给出的J2EE 相关技术主要分为几大块. 1. Web Service技术 - Java API for XML Processing (JAXP) - Java API for XM ...
- 第二百八十七天 how can I 坚持
终于把假请下来了,没有想象的那么复杂. 忘退车票了.明天应该有手续费了,现在又维护了,哎.10%的手续费了.7块钱,没了.希望不会白回去一趟啊. sql,group by having .还是学不会 ...
- ecstore b2b2c 商城页面伪静态代码 及相关注意事项
一下代码需要添加到 nginx.conf配置文件的server块,阿里云虚拟机一般在conf文件夹下建立vhost文件夹,把server块放进去,然后 在nginx.conf使用include 包含进 ...
- AutoCAD.NET二次开发:创建自定义菜单的两种方法比较
目前我已经掌握的创建CAD菜单方法有两种: COM方式: http://www.cnblogs.com/bomb12138/p/3607929.html CUI方式: http://www.cnblo ...
- [iOS 多线程 & 网络 - 2.11] - ASI框架上传文件
A.ASI的上传功能基本使用 1.实现步骤 (1)创建请求 使用ASIFormDataRequest (2)设置上传文件路径 (3)发送请求 2.上传相册相片 UIImagePickerCon ...