Professional Documents
Culture Documents
com/article/hierarchical-data-database/2
You can see all the messages are gone!!! You can see this is a nearly empty page!
As the name says, 'home.ctp' is the default homepage for your website. You can
write anything here (with HTML tags). Those will be displayed at your homepage.
'default.ctp' is the default layout to display your content. If it is empty, CakePHP will
display nothing. This is exactly what you see after saving default.ctp - a completely
blank page!!!
Just copy and paste the following code in the newly created 'default.ctp' file.
--: BEGIN COPY :--
echo $html->css('cake.generic');
echo $scripts_for_layout;
?>
</head>
<body>
<div id="container">
<div id="header">
Header Elements Will Go Here
</div>
<div id="content">
</div>
<div id="footer">
Footer Text Goes Here!
</div>
</div>
<?php echo $cakeDebug; ?>
</body>
</html>
----: END COPY :---
NOTE:
There are FOUR IMPORTANT VARIABLES
$title_for_layout
$scripts_for_layout
$content_for_layout
$cakeDebug
<title>
<?php echo $title_for_layout; ?>
</title>
As such, CakePHP gives a default title to every content page of your website following its own
rules. But you can set a custom title as well. I'll show that in the next page.
NOTE: 2
$scripts_for_layout MUST be included before the closing </head> tag.
NOTE: 3
$content_for_layout MUST be included in between <body>
</body> tag.
<body>
<?php echo $content_for_layout; ?>
</body>
NOTE: 4
$cakeDebug SHOULD be placed before closing </body>
AND you are done! You can add any CSS style/'div' layer to this page ('default.ctp') to give your
website the layout/look you want.
For example, I tried a simple TWO Column Layout.
<div id="content">
<div id="menu-box">
menu items go here!
</div>
<div id="content-box">
<?php $session->flash(); ?>
<?php echo $content_for_layout; ?>
</div>
</div>
I have added one div layer 'menu-box' and another one 'content-box' to display menu items and
content items in two separate columns.
Now I need to add these CSS styles in a stylesheet file.
Modifying Stylesheet
I preferred to go to the bottom of that page and type the following lines
/* Custom CSS */
#menu-box{
width:250px;
float:left;
}
#content-box{
width:700px;
float:left;
}
Here is the code: (Remember: I added the code at the bottom of cake.generic.css file.)
/* Custom CSS */
#menu-box{
width:250px;
float:left;
border-right:1px solid #CCCCCC;
}
#content-box{
margin-left:10px;
width:700px;
float:left;
border:1px solid #CCCCCC;
padding:10px;
background-color:#F3F3F3;
}
#header {
height:100px;
width:100%;
color:#000000;
background-color:#b5fad1;
font-size:2.0em;
border-bottom:1px solid #cccccc;
}
body
{
background-color:#FFFFFF;
color:#000000;
font-family:Verdana, Arial, Helvetica, sans-serif;
}
#footer
{
text-align:center;
}