Professional CodeIgniter, Thomas Myer

Chapter 5: Building a Shopping Cart
113


Adding the View Cart Link to the Navigation

The second part of the Shopping Cart is very simple. You simply add a link that says " view cart " to the
main navigation if there are items in the customer ' s Shopping Cart.

To do this, simply adjust the header view to look for contents in the cart session variable. If the cart
contains information, then show the link.
<
a href="
<
?php echo base_url();?
>
"
>
<
img src="
<
?php echo base_url();?
>
/images/logo.jpg" border="0"/
>
<
/a
>
<
div
>
<
?php echo anchor("welcome/about_us","about us");?
>
&
nbsp;
<
?php echo anchor("welcome/contact", "contact");?
>
<
?php
if (count($_SESSION[`cart']) == true){
echo "
&
nbsp;". anchor("welcome/cart", "view cart");
}
?
>

Figure 5 - 3

What you should end up with is something that looks like Figure 5 - 3 .
c05.indd 113
c05.indd 113
6/10/08 5:35:16 PM
6/10/08 5:35:16 PM


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.