Question

I've joined a screenshot showing the multiple tables. I would like the paginator to work with multiple "shown" tables although they are all originating from the same query. Note that the 'Id' column is one of many columns.

 var $paginate = array(
            'limit' => 1000);

    function index() {
            $this->Immeuble->recursive = 1;
            $this->Immeuble->contain('Agence');
            $this->set('results', $this->paginate());
            $agences = $this->Immeuble->find('count', array('fields' => 'DISTINCT Agence.Nom'));
            $this->set('agences',$agences);
            $ii = 0;
            $records = $this->Immeuble->find("all",array('fields'=>'Immeuble.id,Immeuble.image,Immeuble.description,Immeuble.start_date,Immeuble.end_date$
            $this->set('records',$records);
            }

Here my paginator part in my view:

<tr>
                       <th><?php echo $this->Paginator->sort('Id','id'); ?></th>
                       <th><?php echo $this->Paginator->sort('description');?></th>
                       <th><?php echo $this->Paginator->sort('start_date');?></th>
                       <th><?php echo $this->Paginator->sort('end_date');?></th>
                       <th><?php echo $this->Paginator->sort('image');?></th>
                       <th><?php echo $this->Paginator->sort('ordre');?></th>
                       <th><?php echo $this->Paginator->sort('agence_id');?></th>
                       <th class="actions"><?php __('Actions');?></th>
</tr>

Sorting won't work, it'll just order ASC, not DESC.

Was it helpful?

Solution

You can use paginate multiple times, since it's just a find call. It will reuse the parameters passed by Cake.

$records = $this->paginate();

You can pass special conditions to this call if you need to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top