Professional CodeIgniter

(singke) #1

Chapter 5: Building a Shopping Cart


140


Here ’ s the category view:

< div id=’pleft’ >
< ?php
echo “ < h2 > ”.$category[‘name’].” < /h2 > \n”;
echo “ < p > ”.$category[‘shortdesc’]. “ < /p > \n”;

foreach ($listing as $key = > $list){
echo “ < div class=’productlisting’ >
< img src=’”.$list[‘thumbnail’].”’ border=’0’ class=’thumbnail’ / > \n”;
echo “ < h4 > ”;

switch($level){
case “1”:
echo anchor(‘welcome/cat/’.$list[‘id’],$list[‘name’]);
break;

case “2”:
echo anchor(‘welcome/product/’.$list[‘id’],$list[‘name’]);
break;
}
echo “ < /h4 > \n”;
echo $list[‘shortdesc’].
“ < br/ > ”. anchor(‘welcome/cart/’.$list[‘id’],’add to cart’).
“ < /div > ”;
}
? >
< /div >

Here ’ s the product view:

< div id=’pleft’ >

< ?php
if ($this- > session- > flashdata(‘conf_msg’)){ //change!
echo “ < div class=’message’ > ”;
echo $this- > session- > flashdata(‘conf_msg’);
echo “ < /div > ”;
}
? >
< ?php
echo “ < img src=’”.$product[‘image’].”’ border=’0’ align=’left’/ > \n”;
echo “ < h2 > ”.$product[‘name’].” < /h2 > \n”;
echo “ < p > ”.$product[‘longdesc’]. “ < br/ > \n”;
echo “Colors: < br/ > \n”;
echo “Sizes: < br/ > \n”;
echo anchor(‘welcome/cart/’.$product[‘id’],’add to cart’). “ < /p > \n”;
Free download pdf