BlakeWilliams
BlakeWilliams

Reputation: 940

CakePHP layout partial?

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.

Upvotes: 2

Views: 5755

Answers (2)

nickf
nickf

Reputation: 546473

You can use elements to render a "mini view" of something.

Upvotes: 1

metrobalderas
metrobalderas

Reputation: 5240

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.

Upvotes: 4

Related Questions