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.
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.
您可以使用元素来呈现某些事物的“迷你视图”。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.