On Wed, Jun 20, 2012 at 7:04 AM, JonStark <[email protected]> wrote: > Ratty, I put your function in the User Model, > > public function countPosts( $userId ){ > $count = $this->Post->find('count', array( 'condition' => > array('user_id' => $userId) ) ); > return $count; > } > > and in my view I try to call it like this : > > <?php > $userId = $this->Session->read('Auth.User.id'); > echo User::countPosts($userId); > ?> > > > but it returns > > Undefined property: View::$Post [CORE/Cake/View/View.php, line 806] > > > Fatal error: Call to a member function find() on a non-object > in /app/Model/User.php on line 64
How are you calling this method? Look closely at the notice before the fatal error: View::$Post. Somehow you're calling the method from the View object. -- 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
