Sunday, February 9, 2014

Paginator isn't sorting

I would like to sort my index list on sequence ASC, but it won't work. If I see the query setup in the CakePHP docs (http://book.cakephp.org/2.0/en/core-libraries/components/pagination.html#query-setup), my paginator settings should look like this:

    public function index()
    {
        $this->Paginator->settings = array(
            'Attraction' => array(
                'conditions' => array(
                    'Attraction.deleted' => null
                ),
                'order' => array(
                    'Attraction.sequence ASC',
                    'Attraction.id ASC'
                ),
                'limit' => 15
            )
        );
        
        $attractions = $this->Paginator->paginate('Attraction');
        
        $this->set('attractions', $attractions);
    }

 But every time I load my index file, the list is sorted on ID.

My HTML sorting links above do work and I'm very happy with that:

<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
    <ul class="nav navbar-nav">
        <li><?php echo $this->Paginator->sort('id', 'id'); ?></li>
        <li><?php echo $this->Paginator->sort('name', 'naam'); ?></li>
        <li><?php echo $this->Paginator->sort('show', 'zichtbaarheid'); ?></li>
        <li><?php echo $this->Paginator->sort('sequence', 'gewicht'); ?></li>
    </ul>
</div>

So can anybody tell me if there's anything wrong with my "order" item in my paginator settings? ;)
Thx! 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: