The Post (Model) object inside the *PostsController* is accessible by: *
$this->Post*, so your line should be:

$post = $this->Post->_findPost($id);

But if the *_findPost()* method is defined inside your controller, you
should use:

$post = $this->_findPost($id);

Because *$this->Post* is the Post Model object (inside the
controller), and*$this
* is the Posts Controller object.

You should give a chance to the blog tutorial on the
CookBook<http://book.cakephp.org/2.0/en/#build-a-blog>
.

Cya,
--
***Thiago Belem*
Desenvolvedor
Rio de Janeiro - RJ - Brasil

+55 (21) 8865.9250
thiagobelem.net
[email protected]

*Skype / gTalk **»* thiago.belem.web
*LinkedIn* *»* br.linkedin.com/in/thiagobelem/pt*
Assando Sites*, curso de CakePHP *»* assando-sites.com.br


2012/2/10 Khady <[email protected]>

> Hye, you can help me to cater this problem.
> I have this problem. I'm using version 2.0.4 (the latest version).
> I'm trying to solve this problem, but it didn't works.
>
>
> Fatal error: Call to a member function _findPost() on a non-object in
> C:\xampp\htdocs\cakecms\Controller\PostsController.php on line 35
>
>
> public function admin_view($id = null) {
>
>                $this->Post->id = $id;
>                if (!$this->Post->exists()) {
>                        throw new NotFoundException(__('Invalid post'));
>
>                }
>            $post = $this->Controller->Post->_findPost($id); //this is line
> 35.
>                $this->set(compact('post'));
>        }
>
>
>
>
> # Protected
>
>        function _findPost($id = null)
>        {
>          $post = $this->Post->find('first', array('conditions' =>
> array('Post.id = ' => $id)));
>          if (empty($post))
>          {
>           $this->Session->setFlash(__('Post not found', true));
>           $this->redirect(array('action'=>'index'), null, true);
>
>        }
>                return $post;
>
> --
> 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