On Mar 29, 1:27 pm, "gerbenzomp" <[EMAIL PROTECTED]> wrote:
> I've put it to rest for a while, and focussed on the development of
> other parts of my Cake app. Today I tried getting your example to work
> again, and this time it worked! I guess that I just didn't understand
> enough of Cake a few weeks ago.
>
> One more question though:
>
> I want to have the same kind of modular menu in every view of all my
> controllers, so I put my components in app_controller, like this:
>
> var $components = array('Test', 'Recent');
>
> The "Recent" component fetches the lastest 10 posts, using:
>
> $data= $this->controller->Post->findAll(NULL, NULL, 'Post.id DESC',
> 10);
>
> When the pr($MenuContext); was in my "posts" view, everything worked
> fine,
>
> but since i moved it into my widget_controller's view, I get the error
> "call to a member function on a non-object".
>
> My actual question is:
> How should I reference objects (posts, articles, comments) from within
> the component, when I want to access them in another controller's
> view.
do it the 'safe' way:
loadModel('MyModel');
$Instance = new MyModel();
$resuls = $Instance->findAll();
$stuff = $Instance->AssociatedModel->findAll();
etc.
...
assuming that the controller has the model you want to use in the
component is in reality a bad practice - I think I should change
that :).
hth,
AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---