Just because you have the controller object in the startup of the
component doesn't mean the model is there and ready yet, I think you
may be making an assumption about the order of events that might not
be valid
On 1/24/07, joericochuyt <[EMAIL PROTECTED]> wrote:
>
> Why do I get this error?
> Fatal error: Class 'Headline' not found in
> C:\server\www\....\app\controllers\components\headline.php on line 10
> It should display newsitems on every page of the site.
> Ps: I'm a newbie on cake, so any help or suggestions are welcome, tnx!
>
> This is the code I use:
> ccake_1.1.12.4205
> db table: headlines
>
> component: components/headline.php
> class HeadlineComponent extends Object
> {
> var $controller = true;
> var $news = array();
>
> function startup (&$controller) {
> $this->controller = $controller;
> $this->Headline =& new Headline();
> }
>
> function getSiteHeadlines() {
> $this->news = $this->Headline->findAll();
> return $this->news;
> }
> }
> ?>
>
> model: model/headline.php
> <?php
> class Headline extends AppModel
> {
> var $name = 'Headline';
> }
> ?>
>
> views: headlines.thtml
>
> app_controller:
> class AppController extends Controller {
> var $components = array('Headline');
> var $helpers = array('Html', 'Javascript', 'Ajax');
>
> function beforeRender()
> {
> $this->set('newsitems', $this->Headline->getSiteHeadlines());
> }
> }
>
> And in default.thtml I set: <?php echo
> $this->renderElement('headlines'); ?>
>
>
> >
>
--
==
S. DeVore
(the old fart) the advice is free, the lack of crankiness will cost you
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---