开发者

CakePHP layout partial?

开发者 https://www.devze.com 2022-12-20 11:42 出处:网络
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

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 s开发者_开发技巧tarted CakePHP tonight.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消