I want to sort an array of data in my index action and one condition 
depends on the id given by the request object (attraction_id). Is there a 
way to set up the paginate component as a controller class method (see 
under)?

<?php

class AttractionCommentsController extends CoasterCmsAppController
{
    public $paginate = array(
        'AttractionComment' => array(
            'conditions' => array(
                'Attraction.id' => *$this*
*->request->params['named']['attraction_id'**]*,
                'AttractionComment.deleted' => null
            ),
            'order' => array(
                'AttractionComment.created' => 'DESC',
                'AttractionComment.id' => 'ASC'
            ),
            'limit' => 15
        )
    );
    
    public function index()
    {
        $this->Paginator->settings = $this->paginate;
        
        $comments = $this->Paginator->paginate('AttractionComment');
        
        $this->set('comments', $comments);
    }

?>


The above code can't handle the request variable (*$this*
*->request->params['named']['attraction_id'**])* within the class method.
So... is there a solution for this or is it required to drop the class 
property and do something like this:

<?php

class AttractionCommentsController extends CoasterCmsAppController
{
    public function index()
    {

        $this->Paginator->settings = array(
            'AttractionComment' => array(
                'conditions' => array(
                    'Attraction.id' => $this->request->params['named'][
'attraction_id'],
                    'AttractionComment.deleted' => null
                ),
                'order' => array(
                    'AttractionComment.created' => 'DESC',
                    'AttractionComment.id' => 'ASC'
                ),
                'limit' => 15
            )
        );         
        $comments = $this->Paginator->paginate('AttractionComment');
        
        $this->set('comments', $comments);
    }

?>

Thx 4 helping!

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

Reply via email to