Hi Alex,

> I have two controller classes:
> class PagesController extends AppController {
> (...)
>     function home() {
>         App::import('Controller', 'NewsPosts');
>         $controller = new NewsPostsController();
>         $this->set('NewsGrouped', $controller->_getNewsGrouped());
>     }
> (...)}
>
> and
> class NewsPostsController extends AppController {
>     var $name = 'NewsPosts';
>     var $uses = array('NewsPost', 'NewsType');
> (...)
>     function index(){
>         $this->set('NewsGrouped', $this->_getNewsGrouped());
>     }
>     function _getNewsGrouped(){
>         $types = $this->NewsType->find('all', array('conditions' =>
> array('max_num >' => 0),
>                                                     'order' =>
> 'NewsType.order'));
> (...)
>     }
> (...)
>
> }
>
> When I callhttp://mysite/news_posts/index, everything works fine, but
> when I callhttp://mysite, that is mapped to PagesController::home
> action, I get an error:
>         Fatal error: Call to a member function find() on a non-object
> in Z:\home\test1.ru\www\app\controllers\news_posts_controller.php on
> line 24
> I can't really understand that, since I use the same scheme in several
> other places and it works fine everytime. What could be the problem??

Call $controller->constructClasses(); after you create an instance of
the controller with $controller = new NewsPostsController();

Hope that helps!

--
Daniel Hofstetter
http://cakebaker.42dh.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to