I was amazed with the simplicity of the CakePHP framework. Its so easy to understand the model view controller and just within minutes we can break down the application like a blog into pieces.
Just i was experimenting i found that making custom layouts with the framework is bit hard to find after i made search in the web. I decided to publish here. You can download and install latest cakephp framework here: cakephp.org
Just a quick tip on basics of CakePHP Framework… You will see lot of files under the cakephp folder.
Model – It interacts/talks with your database like SQL queries. It is always singular like post.php
Controllers – It defines the basic logic of the application. Like you can add, delete, edit operations for a particular data. It is always written in plural form like posts_controller.php
Views – Basically shows how output is presented/
You should install in such a way that main page is /cakephp/app/webroot
To create a custom layout just look for folder named /cakephp/app/views/layouts. Just create a default layout and place it there. The file should be named default.thtml
Demo Header Page
Demo (c) Footer Page
once you create default layout page sure you have 2 php variables $content_for_layout and $title_for_layout there
You can create as many different layout and place them inside the layout folder. For a specific view to display the customized layout, make sure you include a line named in the controllers file like this.
var $layout = 'main';
inside your controllers code.
Similar Posts:
- Cakephp vs CodeIgniter – which is best php framework?
- bind /etc/named.conf missing
- WordPress – how to add custom field when post is published?
- WordPress – How to create a login protected page?
- Fixing WordPress custom permalinks 404 error
- How to add adsense code to vanilla forum?
- how to change default homepage with htaccess?
- How to insert logo in your wordpress blog?
- 10+ Great PHP Scripts to create a Social Network
- Affiliate Hide – Free wordpress plugin to redirect affiliate links!


July 2, 2007
Damn your blog theme looks familiar
Yeah, I’m just like you. Just got into the whole CakePHP framework. My jaw is still a lil’ bit on the floor with all that it can do.
Have you looked at the “bake” option? It’s basically a wizard (in a console) that automatically creates models, controllers and views for you.
–
Baz L
Baz Web Development
August 19, 2008
can I use my own design with CakePHP ? there are any tutorial ?
March 15, 2010
V.good, can I use my own design with CakePHP ? there are any tutorial ? i have desing and i need to use my layout. how can i use it ?
May 19, 2010
I am newbie in cake php and I was just searching for the solution u had explained. Gr8 topic and I rate this tutorial 10/10…thanks
March 25, 2011
var $layout = ‘main’;
it should be var $layout = ‘default’;