Professional CodeIgniter

(singke) #1

Chapter 4: Creating the Main Web Site


87


As you can see, there ’ s practically the same number of lines and the same kinds of constructs. It ’ s your
choice.

Here ’ s a reminder of how those two arrays ( $mainf and $sidef ) were called in the controller function
index() :


$home[‘mainf’] = $this- > MProducts- > getMainFeature();
$skip = $home[‘mainf’][‘id’];
$home[‘sidef’] = $this- > MProducts- > getRandomProducts(3,$skip);
$data[‘main’] = $this- > load- > view(‘home’,$home,true);

You ’ re not quite done with the home page; you will need to make some changes to the /css/default.css file
you started in Chapter 3. Not only will you be adding new entries (for the new divs), but you ’ ll also need to
adjust some other layout rules. For example, you notice that the web site as a whole is much too wide for
most monitors, so you decide to knock it down from 1,000 pixels (1000px) to 800 pixels (800px) in width.

Here is the complete CSS, with changes in bold:

/* default css */

body{
background-color:white;
font-family: Arial, Verdana, sans-serif;
margin:0;
padding:0;
}

#wrapper{
width:800px;
margin:10px auto;
padding:10px;
background-color:#f1f1f1;
border:2px solid #ccc;
}

#nav{
float:left;
width:135px;
height:auto;
}

#main{
margin-left:150px;
width:600px;
height:auto;

}
Free download pdf