Saturday, January 23, 2010

Cook a Custom CakePHP Template

You have seen bellow messages in the welcome screen has changed after each of your action.

Editing this Page

  • To change the content of this page, create: APP/views/pages/home.ctp.
  • To change its layout, create: APP/views/layouts/default.ctp.
  • You can also add some CSS styles for your pages at: APP/webroot/css.
Creating a default home page

To create a default home we need to create a folder named "pages" under app/view/ and put file name "home.ctp" your can write anything on that page it will display there.

use cake php file extension as .ctp use and text editor and save file as .ctp

Creating layout

under under 'app/views/layouts/' folder create a "default.ctp" file
now it will display a blank page - to see content and to give link do following things


Please copy paste above code to defalut.ctp now you can view layout i marked some things in red mark now , Page title is "First Test"

  1. $title_for_layout
  2. $scripts_for_layout
  3. $content_for_layout
  4. $cakeDebug
$title_for_layout : that must comes in between title tag , it is helps you to put default title in all pages amd also can put custom tilte like "First test"

$scripts_for_layout : will come under header part helps you to put scripts

$content_for_layout :that must come under body


$cakeDebug : will put after body

now echo $html->css('style'); : creating a css named style.css file and this file can placed under
APP/webroot/css.

Now you can view bellow layout , and i made it please try your self with differnt design



No comments: