pagination: what is my fault?

Hello,

i'd like to sort ascending and descending in my table columns. First of all, i'd lile to sort by the field "inventory_number" in the model "HardwareUnit" (table "hardware_units"). So i have written the following source:

Controller:


var $paginate = array(
    'limit' => 25,
    'order' => array(
    'HardwareUnit.inventory_number' => 'asc'
    )
  );

view:


<th><?php echo $paginator->sort(array('asc' =>'inventory_number ^', 'desc' =>'inventory_number v'), 'inventory_number');  ?></th>

I get the following error message:

Notice (8): Undefined variable: paginator [APP\views\hardware_units\index.ctp, line 37]

Fatal error: Call to a member function sort() on a non-object in C:\Program Files (x86)\Apache Software Foundation\cake\app\views\hardware_units\index.ctp on line 37

(line 37 is the source of my view, which i have included above)

Thanks if someone can help!

Greetings!

SOLUTION:

my new controller:


<?php 
class HardwareUnitsController extends AppController
{
	var $name = 'HardwareUnits';
  
  var $paginate = array(
    'limit' => 25,
    'order' => array(
    'HardwareUnit.inventory_number' => 'asc'
    )
  );
  
	function index()
	{
	  $data = $this->paginate('HardwareUnit');
    $this->set('hardware_units', $data); 
	}
  

Asked by sebb86, on 15/1/10

1 Answer

you need to call the paginate method $this->paginate()

Answered by dogmatic69on 15/1/10

hmm,

the formatting fails...

i add the new controllerto the question-post.

sebb86 - on 15/1/10

<< comments | 1 | 2
<< previous next >>

Tagged with

Rating

0

Viewed

348 times

Last Activity

on 15/1/10