sv3tli0/paginate

该包已被弃用且不再维护。没有建议的替代包。

分页生成器

dev-master 2014-04-11 14:47 UTC

This package is not auto-updated.

Last update: 2018-12-08 12:44:06 UTC


README

示例

 $config = array(
 	'totalItems'		=> 1234,
	'itemsPerPage'		=>	20,
	'displayedPages'	=>	7,
	'method'			=>	'query',
	'param'				=>	'page',
	'show_PrevNext'		=>	TRUE
);
$paginate = new Paginate($config);

公共函数

 # returns all pages, ready to be loaded in a template.
function getPages(){}

# returns builded pagination HTML
function renderHtml($layout, $engine = FALSE, $engineObject = FALSE){} 

# get current page numb 
function getCurrent(){}

# get offset limit for queries
function getOffset(){}

# Set totalItems if you cant count them on class init
function setTotalItems($totalItems){}

# Set current page - overwrites if there is set.
function setCurrentPage($page){}

# Resets any param from the init params
function setParam($item, $value){} 

# Resets any param from the init params for multiple elements ($params must be array!)
function setParams($params){} 

renderHtml函数的参数

  • $layout - 布局文件的完整路径。您可以在示例中查看布局
  • $engine - 模板引擎。目前您可以设置为
    • FALSE 或什么也不设置 = 将加载纯PHP代码
    • smarty - 这将使用smarty模板引擎来构建您的模板
  • $engineObject - 如果在此处选择$engine,则传递其对象!注意!Paginate类不会创建任何模板引擎对象。因此,您只能传递TE对象!

可用于配置的参数

  • totalItems - 总项目!必需!在构造函数中,它是设置在之后的第一个参数,之后是一个包含所有其他参数的数组。
  • itemsPerPage - 每页所需的项目数量,用于计算页数。
  • displayedPages - 要显示的最大页码链接数。
  • baseUrl - 生成页面和捕获当前页的基础URL。
  • current - 如果您想固定当前页,可以设置当前页。
  • method - 获取/设置页面的方法(查询或段)
    • param = 对于方法query必需!这等于$_GET参数
    • segment = 对于方法segment必需!这等于URL中由斜杠分隔的段ID:“domain/1/2/3/4/5/6/..”
  • 选项
    • show_PrevNext - 显示上一页和下一页按钮
    • show_FristLast - 显示第一页和最后一页按钮
    • FirstToLast - 按顺序显示页面:1 [分隔符] 7 8 9 [分隔符] 最后一页
  • 上一页/下一页数组
    • prevName - 上一页按钮的值(默认:'<<')
    • nextName - 下一页按钮的值(默认:'>>')
  • 第一页/最后一页数组
    • firstName - 第一页按钮的值(默认:'First')
    • lastName - 最后一页按钮的值(默认:'Last')

在调用时

<script data-gittip-username="sv3tli0" src="//gttp.co/v1.js"></script>

Flattr this git repo