Got it - thanks. So you're really just setting up the paginate variable in the model rather than the controller then calling it from the controller to set up pagination before doing a paginate find?
On 24 May 2013, at 05:25, "Advantage+" <movepix...@gmail.com> wrote: > Not sure if this is any help. But I hate all the $params in the controller > especially if you have to do it on the fly so I set all the params in the > model like such: (Just swap out 'model' for your own ) > Model: > public function _Pagination($limit = 15){ > > $params = array( > 'conditions' => array( > > 'fields' => array( > > 'Model.id', > > 'Model.featured', > > 'Model.title', > > 'Model.description), > > 'limit' => $limit, > > 'order' => array( > > 'Model.created DESC'), > > 'contain' => array( > > 'State' => array( > > 'fields' => array( > > 'State.abrev')), > 'Country' => > array( > > 'fields' => array( > > 'Country.name', > > 'Country.iso'))); > > return $params; > } > > Controller: > $this->paginate = $this->Model->_Pagination ($anything you want to pass > $limit, $conditions…….); > And just pop it into the find into the $params like > > $this->paginate = $this->Model->_Pagination($limit = 10); or anything you > might want to edit on the fly. > > Swap out all the vars you want and make it work for you. > Then do standard: > > $this->set('whatever', $this->paginate('Model')); > > All it is basically is the same as you normally would do in the controller > but rather than having all that crap I find it easier to say paginateThis(), > pagginateThat() rather than all that in the controller and just pull the > params from the model. > > Dave > > From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf > Of Jeremy Burns : Class Outfit > Sent: Friday, May 24, 2013 1:00 AM > To: cake-php@googlegroups.com > Subject: Re: CakePHP 2.x Moving Find into Model > > Have you got an example of that? > > On 24 May 2013, at 01:09, lowpass <zijn.digi...@gmail.com> wrote: > > > Apply the array to the $paginate class var, not the method. Basically, you > can declare the $paginate array as a class var, then add to or override any > part of it from within an action. > > > On Thu, May 23, 2013 at 7:12 PM, Larry Lutz <lut...@swbell.net> wrote: > I'm trying to achieve the fat model/skinny controller mantra in CakePHP 2.7. > In that scenario, the model should control the data, and that means moving > the finds out of the controllers and into the models. However, at least with > the view and admin_view actions, one needs the data paginated. > > The problem starts there. It's easy enough to do a $this->find('all') in the > model to get the data, along with any conditions, contains, etc. However that > produces an array. Paginator->paginate(), as far as I can tell won't work in > the model; it's a component that only works in a controller. Yet, if I take > the array produced in the model into the controller and try to pass it on > toPaginator->paginate(), it fails because paginate won't accept an array. > > In terms of trying to achieve the fat model/skinny controller goal, what am I > missing here. How can I achieve a paginated result while still having the > model (properly) do the work of managing and finding the data? > > -- > 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?hl=en. > 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?hl=en. > 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?hl=en. > 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?hl=en. > 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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.