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." <contact.mysparet...@gmail.com> 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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment