Hey guys I have a question regarding pagination and filters of the
pagination in cake 1.3 . In my index function I have created a filter
on top. It's a simple form, and if not empty $this->data on index
function I apply conditions for pagination.

Example :
if (!empty($this->data)) {
                        $date=strtotime($this->data['Invoices']['from']);
                        $start = date('Y-m-d',$date);

                        $date=strtotime($this->data['Invoices']['to']);
                        $end = date('Y-m-d',$date);

                        array_push($cond,array('Invoice.date >='=>$start ));
                        array_push($cond,array('Invoice.date <='=>$end ));
}

and so on for the 4 other params.

After making conditions I set the data for view this way:

$this->paginate = array('conditions' => $cond,
                        'order' => array('Invoice.created' => 'desc')
                        );
$data = $this->paginate('Invoice');
$this->set('invoices', $this->paginate());

In the view I display data like this :

example : <th><?php echo $this->Paginator->sort('date');?></th>
and below in td's somthing like <td><?php echo $invoice['Invoice']
['date']; ?>&nbsp;</td>

The problem comes when a person wants to sort filtered data by
clicking on the date label of the table with the data or any other
label in the whole table. The pagination just resets to default find
all, plus gives the sort function of clicked label. I need to preserve
filter conditions but I don't know how to override the link in the
head of the table.

Is there a way cake can to this , such as set the sort behavior or do
I just have to make table header without this : <?php echo $this-
>Paginator->sort('date');?> but to make my own links for this purposes
which would be generated every time somebody filters index page.

Or , is there some better way to do this in all ?

Thank you in advance,
Milos



-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to