Professional CodeIgniter

(singke) #1

Chapter 5: Building a Shopping Cart


131


the second segment (as in “ welcome/index ” ) to see if it matches “ index ” or not. Before, you were
possibly looking at the third segment, which would serve as an argument to a controller function (i.e.,
the 5 would serve as an argument to category() in /welcome/category/5).

< a href=” < ?php echo base_url();? > ” >
< img src=” < ?php echo base_url();? > images/logo.jpg” border=”0”/ >
< /a >

< div id=’globalnav’ >
< ul >
< ?php
if ($this- > uri- > segment(2) != “index”){
echo “ < li > ”.anchor(“welcome/index”,”home”).” < /li > ”;
}
? >
< li > < ?php echo anchor(“welcome/about_us”,”about us”);? > < /li >
< li > < ?php echo anchor(“welcome/contact”, “contact”);? > < /li >
< ?php
if (count($_SESSION[‘cart’])){
echo “ < li > ”. anchor(“welcome/cart”, “view cart”). “ < /li > ”;
}
? >

< li >

< ?php
echo form_open(“welcome/search”);
$data = array(
“name” = > “term”,
“id” = > “term”,
“maxlength” = > “64”,
“size” = > “15”
);
echo form_input($data);
echo form_submit(“submit”,”search”);
echo form_close();
? >
< /li >
< /ul >
< /div >

Now all you have to do is update the CSS by adding a series of rules to handle the globalnav < div > and
its < ul > list.


The first thing you need to do is set the rules for the globalnav < div > itself. You want a box with a dark
background, 600 pixels wide by 30 pixels high (using this width value will make the navigation bar as
wide as the logo):


/* navigation */

#globalnav {
width: 600px;
height:30px;
Free download pdf