I've been pulling my hair out on this for a while now, and it just
seems like the pagination sorting isn't working correctly.

Using the defaults views/controllers created by cakebake, I get these
headers in my view and this index function in my controller.

<th><?php echo $paginator->sort('name');?></th>
<th><?php echo $paginator->sort('cas_num');?></th>

        function index() {
                $this->Ingredient->recursive = 2;
                $this->set('ingredients', $this->paginate());
        }


But it only sorts the fields ascending. Once you click to sort by that
field, it does not automatically change the link to sort the same
field descending. So, if you click Name, you get Name ascending, no
matter how many times you press it.



I've even tried to force it to create the link differently by passing
the arguments sent to my controller:
$this-params['named']['sort'] and
$this-params['named']['direction']

BACK to my view, and then doing if statements:

<th><?php
        if ($sortField == 'cas_num' && $sortOrder == 'asc'){
               echo $paginator->link('Cas Num', array('sort' =>
'cas_num', 'direction' => 'desc'));
        } else {
                echo $paginator->link('Cas Num', array('sort' => 'cas_num',
'direction' =>'asc'));

        ?>
</th>

And the $sortField and $sortOrder variables are being set fine. I've
been checking them with outputs. And it is calling this function
correctly:

               echo $paginator->link('Cas Num', array('sort' =>
'cas_num', 'direction' => 'desc'));

But it is NOT creating a link that sets the direction to desc. The
link it creates is STILL an ASC link.


I don't know what I'm doing wrong. I would be so very appreciative of
anyone that can shed some light on this for me!!

Thank you!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to