Reputation: 5803
How to give a sorting using paginate.. and how to set a limit also...
my code is :-
in controller :-
$this->paginate('ProductZone');
in view ctp:-
<th><?php echo $this->Paginator->sort('TDU','ProductZone.zone_id'); ?> </th>
<th><?php echo $this->Paginator->sort('Energy Charge','ProductZone.energy_charge'); ?></th>
<th>500 KwH(¢/kWh)</th>
<th>1000 KwH(¢/kWh)</th>
<th>2000 KwH(¢/kWh)</th>
<th>Plan Desc</th>
Upvotes: 0
Views: 152
Reputation: 540
You use the paginate property to set the paginate method settings.
$this->paginate = array(
'ProductZone' => array(
'conditions' => array(
'ProductZone.active' => true,
'ProductZone.id' => 10,
),
'order' => 'ProductZone.created DESC',
'limit' => 10
)
);
$product_zones = $this->paginate('ProductZone');
$this->set(compact('product_zones'));
Upvotes: 1