彭诺罗斯福/cakephp-pagination-cache

CakePHP 3.x 的分页缓存插件

1.0.0 2017-01-25 18:58 UTC

This package is auto-updated.

Last update: 2024-09-16 06:55:11 UTC


README

Software License Total Downloads Latest Stable Version Build Status Coverage Status

安装

您可以使用 composer 将此插件安装到您的 CakePHP 应用程序中。

安装 composer 包的推荐方法是

composer require brenoroosevelt/cakephp-pagination-cache

加载插件

将以下内容添加到您的 config/bootstrap.php

Plugin::load('BRPaginationCache');

使用方法

控制器类

public function index()
{

		// load component with setup param
		$this->loadComponent('BRPaginationCache.PaginationCache', [
				'session' => 'posts_pagination'
		]);
		
		// restore pagination from session
		$this->PaginationCache->restore();
		
		// pagination		
		$this->set('posts', $this->paginate($this->Posts));
		
		// save pagination from session
		$this->PaginationCache->save();
}

持久化分页参数(会话)

所有参数都使用会话持久化。请确保加载 Session 组件。