Prev | Current Page 258 | Next

Emilian Balanescu and Cristian Darie

"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"

image_2}"
alt="{$obj->mProduct.name} image 2" />
{/if}

{$obj->mProduct.description}


CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 167


Price:
{if $obj->mProduct.discounted_price != 0}
{$obj->mProduct.price}
{$obj->mProduct.discounted_price}
{else}
{$obj->mProduct.price}
{/if}


{if $obj->mLinkToContinueShopping}
Continue Shopping
{/if}

Find similar products in our catalog:



    {section name=i loop=$obj->mLocations}

    {/section}

3. OK, now create the componentized template for the product details page in which the product with full
description and a second image will display. Create a file named product.php in the presentation
folder with the following contents:
// Handles product details
class Product
{
// Public variables to be used in Smarty template
public $mProduct;
public $mProductLocations;
public $mLinkToContinueShopping;
public $mLocations;
// Private stuff
private $_mProductId;
CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 168
// Class constructor
public function __construct()
{
// Variable initialization
if (isset ($_GET['ProductId']))
$this->_mProductId = (int)$_GET['ProductId'];
else
trigger_error('ProductId not set');
}
public function init()
{
// Get product details from business tier
$this->mProduct = Catalog::GetProductDetails($this->_mProductId);
if (isset ($_SESSION['link_to_continue_shopping']))
{
$continue_shopping =
Link::QueryStringToArray($_SESSION['link_to_continue_shopping']);
$page = 1;
if (isset ($continue_shopping['Page']))
$page = (int)$continue_shopping['Page'];
if (isset ($continue_shopping['CategoryId']))
$this->mLinkToContinueShopping =
Link::ToCategory((int)$continue_shopping['DepartmentId'],
(int)$continue_shopping['CategoryId'], $page);
elseif (isset ($continue_shopping['DepartmentId']))
$this->mLinkToContinueShopping =
Link::ToDepartment((int)$continue_shopping['DepartmentId'], $page);
else
$this->mLinkToContinueShopping = Link::ToIndex($page);
}
if ($this->mProduct['image'])
$this->mProduct['image'] =
Link::Build('product_images/' .


Pages:
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270
transport odpadów miedzyzdroje hotel upadlanych.waw.pl online loans for bad credit history asus netbooki