See the 'order' param for $hasMany: http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html
On Fri, Jul 19, 2013 at 8:18 PM, Advantage+ <movepix...@gmail.com> wrote: > By default I assume for example Gallery hasMany Image.**** > > When I view the specific gallery (as admin, straight tables as baked) I > see all the related images. Now I built in a drag and drop to order the > images how I want, but they are being sorted by Cake I assume by the id. So > even though I have the order set as 1, 2, 3 they get displayed as say 2,3,1 > **** > > Is there a built in way to sort by a specific field for the related > Image(s) or simply need to build a custom method to fetch as I want it?*** > * > > ** ** > > Standard bake produces:**** > > public function admin_view($id = null) {**** > > $this->Gallery->id = $id;**** > > if (!$this->Gallery->exists()) {**** > > throw new > NotFoundException(__('Invalid %s', __('gallery')));**** > > }**** > > $this->set('gallery', > $this->Gallery->read(null, $id));**** > > }**** > > ** ** > > Simply replace $this->set('gallery', $this->Gallery->read(null, $id));with a > custom find > **** > > $this->set('gallery', $this->Gallery->getGallery($id)); and do the sort > Image within that? Or is there a built in method to take care of how you > want related records sorted?**** > > ** ** > > Thanks,**** > > ** ** > > Dave**** > > -- > 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+unsubscr...@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. > > > -- 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+unsubscr...@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.