FrontEnd Expert
FrontEnd Expert

Reputation: 5803

cake php pagination issue in

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(&#162;/kWh)</th>
            <th>1000 KwH(&#162;/kWh)</th>
            <th>2000 KwH(&#162;/kWh)</th>
            <th>Plan Desc</th>

Upvotes: 0

Views: 152

Answers (1)

Wil
Wil

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

Related Questions