This blog is about the PHP solutions I have to think of when I'm developing systems almost every single day...

Wednesday, January 30, 2008

Rendering page elements in CakePHP

Most of the time, a web application will have some parts which are pretty constant no matter what you are viewing or editing. How to render these parts are not directly obvious since most of the CakePHP tutorials focus on developing the MVC parts of the application. After much code digging in some CakePHP applications, I've concluded that it is done using the renderElement function. You'll use it something like this in your app/views/layouts/default.ctp:

<?php $this->renderElement('mainmenu'); ?>

And then you'll have to create the file mainmenu .ctp in the app/views/elements directory. Piece of CakePHP eh.. ;)

0 comments: