Re: Use classes from a different controller

2011-12-26 Thread euromark
but... slim controller, fat model that's why you should have used $this->Model->ownPosts($uid) as I wrote earlier. but, well, what the heck :) On 26 Dez., 12:45, "J." wrote: > Perfect, it works. > > Here is the solution (posting it because it may help some people) > >     public function view($

Re: Use classes from a different controller

2011-12-26 Thread J.
Perfect, it works. Here is the solution (posting it because it may help some people) public function view($id = null) { $this->loadModel('Item'); $items = $this->set('items', $this->Item->find('all', array('conditions' => array('Item.ownerid' => $id; $this->User->i

Re: Use classes from a different controller

2011-12-26 Thread Tilen Majerle
http://book.cakephp.org/2.0/en/models/retrieving-your-data.html look at this post :) -- Lep pozdrav, Tilen Majerle http://majerle.eu 2011/12/26 J. > Thanks ! This worked : > > $this->loadModel('Post'); >$posts= $this->set('posts', $this->Post->find('all')); > > If I may ask a last ques

Re: Use classes from a different controller

2011-12-26 Thread J.
Thanks ! This worked : $this->loadModel('Post'); $posts= $this->set('posts', $this->Post->find('all')); If I may ask a last question : This returns ALL posts. I want to display only owned posts. How should I replace "all" by my $ownerid variable ? On 25 déc, 22:36, euromark wrote: >

Re: Use classes from a different controller

2011-12-25 Thread euromark
classic design failure you shouldn't (ever) use a controller in another controller design your actions the way that they use the model to get the data this way you can call these model methods from other controllers, as well so it boils down to $this->Model->ownPosts($uid) etc On 25 Dez., 19:1

Use classes from a different controller

2011-12-25 Thread J.
Hello. I'm building an app derivated from the cakephp blog tutorial. On the User profils, I want to display which posts they own (my posts have a owner_id field) with a foreach. But to use the classes from my Posts Controller in my UsersController, I used this code : App::import('Controller', '