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. <[email protected]>

> 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 <[email protected]> wrote:
> > 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:13, "J." <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > 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', 'Posts');
> >
> > > $Posts = new PostsController;
> >
> > > $Posts->constructClasses();,
> >
> > > but when doing this :
> >
> > > <?php foreach ($posts as $post): ?>
> >
> > > I get this on the page :
> >
> > > Undefined variable: posts [APP/View/Users/view.ctp, line 78]
> >
> > > and
> >
> > > Warning (2): Invalid argument supplied for foreach() [APP/View/Users/
> > > view.ctp, line 78]
> >
> > > I'm new to cake and php, so I really don't understand what's the
> > > problem here.
> >
> > > thanks for your time and merry Christmas !
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to