In my CakePHP application layout I have a section for latest posts that needs to pull from a database. How would I tell it to render a partial so I can pull the latest posts? Sorry if this is a simple question, I just started CakePHP tonight.
So I could put that in my default.ctp in my layouts folder and it would pull from the database right? Sorry if I sound stupid/confused, but I just ported all my kohana stuff to cakePHP and it's a little troublesome to get everything all figured out.
TheMoonMaster
2010-02-19 04:39:35
@TheMoonMaster An element is just a reusable HTML/PHP "view snippet". To get data into it you can set the data in the controller and pass it into the element, or you can "pull" the data from inside the element using `requestAction`. This is explained in the article nickf links to.
deceze
2010-02-19 04:48:13
Awesome, thanks guys.
TheMoonMaster
2010-02-20 02:19:35
A:
As nickf said, you can use elements. Just create a latest-posts.ctp
file in views/elements
. There you can create a recyclable element.
Now, on views/layouts/default.ctp
$this->render('latest-posts');
There you go.
metrobalderas
2010-02-19 04:43:37