info@ektanjali.com +91 99276-99286

CakePHP 2.x User Management Premium Plugin Version 2.3.x

Pagination

I have developed a nice Pagination in this plugin which is very attractive. This pagination can also be used out side the plugin in your project.

How to use pagination in Cake Php
1. set pagination variable in your controller for e.g. in UsersController.php

public $paginate = array(
            'limit' => 25
        );


2. Now in any function you should get results from Database in following way for e.g. in index function

$this->paginate = array('limit' => 10, 'order'=>'User.id desc');
$users = $this->paginate('User');

$this->set('users', $users);

3. Now in View file you should add pagination element in following way for e.g. in index.ctp after the results table

<?php if(!empty($users)) { echo $this->element('Usermgmt.pagination', array("totolText" => "Number of Users")); } ?>

where
$users is result variable, set from controller's index function.
'pagination' is a pagination element location is yourapp/app/Plugin/Usermgmt/View/Elements/pagination.ctp.
'totolText' is a total text to be displayed on pagination bar.

For more information see
Users Controller yourapp/app/Plugin/Usermgmt/Controller/UsersController.php
Index View yourapp/app/Plugin/Usermgmt/View/Users/index.ctp
Pagination Element yourapp/app/Plugin/Usermgmt/View/Elements/pagination.ctp