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.
On 12 mrt, 16:40, "gerbenzomp" <[EMAIL PROTECTED]> wrote:
> Strange, I do use the requestHandler in my app_controller.
>
> Line 213 is:
> if ((!$this->auto) || isset ($controller->params['requested']) ||
> $controller->RequestHandler->isAjax() || ($this->Session-
>
> >read('Config.components') === '0')) {
> //...
> }
>
> Gerben.
>
> On 12 mrt, 11:40, "AD7six" <[EMAIL PROTECTED]> wrote:
>
> > On Mar 12, 10:28 am, "gerbenzomp" <[EMAIL PROTECTED]> wrote:
>
> > > Hi AD!
>
> > > Thanks for your reply!
>
> > > Ok, I'm beginning to see it:
>
> > > I've created a new component: test.php in controllers/components
>
> > > class TestComponent extends TemplateComponent {
> > > var $name= 'Test';
>
> > > function _getData() {
> > > // some data for testing purposes
> > > $data = 'hello world';
> > > return $data;
> > > }
>
> > > }
>
> > > In my posts_controller I added:
>
> > > var $components = array ('Test');
>
> > > And in views/posts/index.thtml:
>
> > > <? php print_r($MenuContext); ?>
>
> > > But I keep getting the error:
>
> > > Call to a member function on a non-object in /var/www/vhosts/zomp.nl/
> > > httpdocs/framework/app/controllers/components/template.php on line 213
>
> > > Maybe I'm still doing something silly, but I don't see it now.
>
> > HI Gerbenzomp,
>
> > What is line 213 for you.
>
> > I would guess that you are currently not using thre requestHandler
> > component, the code assumes you have it declared in your app
> > controller. You can just remove that test, which isn't in that form
> > any more in my dev env.
>
> > 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
-~----------~----~----~----~------~----~------~--~---