Paginator Helper in CakePHP
Cake php provide inbuilt pagination we can use this by using Paginator Helper.To use pagination first we need to use Paginator Component public $components = array('Paginator','Auth'); now add the below code in your controller here i am using pagination for users table
public function index() {
$this->User->recursive = 0;
$this->set('users', $this->Paginator->paginate());
}
Now in your view add below code
<table cellpadding="0" cellspacing="0">
<thead>
<tr>
<th><?php echo $this->Paginator->sort('id'); ?></th>
<th><?php echo $this->Paginator->sort('username'); ?></th>
<th><?php echo $this->Paginator->sort('password'); ?></th>
<th><?php echo $this->Paginator->sort('group_id'); ?></th>
<th><?php echo $this->Paginator->sort('created'); ?></th>
<th><?php echo $this->Paginator->sort('modified'); ?></th>
<th class="actions"><?php echo __('Actions'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($users as $user): ?>
<tr>
- See full Blog at: Paginator Helper in CakePHP
FindNerd is the right place to resolve PHP language problems. Here you can post PHP Questions and Answers.
If you have any query on PHP language, Post it at FindNerd’s – PHP Developer Forum.
Advertise on APSense
This advertising space is available.
Post Your Ad Here
Post Your Ad Here
Comments