I have a list of ordered items ordered according to int field order. I am creating a gallery in CakePHP 1.2 that has a previous and next button, and they should refer to the previous and next elements according to their order, and not according to them id.
To get this result, I included the "order" parameter in the search function and populated it 'Item.order'=>'DESC'. However, the result is an ordered list id.
My question is: what am I doing wrong? My controller:
$this->Item->id = 16;
$neighbours = $this->Item->find('neighbors', array('order'=>array('Item.order'=>'DESC'), 'fields'=>array('id','name')));
Solution
I tried a different approach. My code now does the job and looks like this:
$order = $this->Item->findById(6);
$neighbours = $this->Item->find('neighbors', array('field'=>'order', 'value'=>$order['Item']['order']));
'field' , , 'value' , prev next.