Thanx manja.
That article was perfect got it to run.
On Sep 20, 10:59 pm, majna <[EMAIL PROTECTED]> wrote:
> function getNews()
> {
> $news = ClassRegistry::init('News');
> $data = $news->find('all', array('limit'=>3,
> 'order'=>'News.date DESC'));
> return $data;
> }
>
> function beforeRender()
> {
> $this->set('latest_news', $this->getNews());
>
> }
>
> But app_controller is not best solution.
> read:http://bakery.cakephp.org/articles/view/creating-reusable-elements-wi...
>
> On Sep 20, 2:22 pm, exo_duz <[EMAIL PROTECTED]> wrote:
>
> > Hi all,
>
> > I'm pretty new to CakePHP and trying to learn it. At the moment I have
> > a news section in the default layout which uses the News model and
> > outputs the latest 3 news from the database.
>
> > At first I thought of using it in the app_controller.php by creating a
> > function in the app_controller:
>
> > function getNews()
> > {
> > $uses = "News";
> > $this->News->findAll("LIMIT 3", NULL, "date DESC");
> > }
>
> > Then using the above function in all the views in the beforeRender:
>
> > function beforeRender()
> > {
> > $this->getNews();
>
> > }
>
> > My question is how do you output the News from the model in the
> > default layout? I read an article that said not to use "$uses" in the
> > app_controller.php. So I assume the above code is mistaken.
>
> > Is there a simpler way to do this?
>
> > Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" 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
-~----------~----~----~----~------~----~------~--~---