JavaScript Editor Ajax software     Free javascripts 



Main Page

// calculate which products to display on this page
$start = ($page - 1) * PRODUCTS_PER_PAGE;
$end = min ($start + PRODUCTS_PER_PAGE, count($products));
// display the products for the current page
for ($i = $start; $i < $end; $i++ )
{
$url = make_category_product_url($category_name, $category_id,
$products[$i][‘name’], $products[$i][‘id’]);
echo ‘<li>’ .
‘<a href=”‘ . $url . ‘“‘ . ‘>’ . $products[$i][‘name’] . ‘</a>’ .
‘</li>’;
}
echo “</ul>”;
// use the SimplePager library to display the pager
$simple_pager = new SimplePager($products, PRODUCTS_PER_PAGE, ‘make_category_url’);
echo $simple_pager->display($page, $products, array($category_name, $category_id));
?>
</body>
</html>
15.
Finally, create
product.php
in your
seophp
folder. This is the page that individual products
appear on:
<?php
// load the catalog library
require_once ‘include/catalog.inc.php’;
// load the URL factory
require_once ‘include/url_factory.inc.php’;
// load the SimpleGeoTarget library
require_once ‘include/simple_geo_target.inc.php’;
// retrieve the product details
$product_id = $_GET[‘product_id’];
$products = Products::get($product_id);
$product = $products[0];
// retrieve the category details and create the category link
$category_id = $_GET[‘category_id’];
$categories = Categories::get($category_id);
$category = $categories[0];
$category_url = make_category_url($category[‘name’], $category[‘id’]);
// redirect to the proper URL if necessary
$proper_url = make_category_product_url($category[‘name’], $category_id,
$product[‘name’], $product_id);
fix_url($proper_url);
// retrieve the brand details
$brand_id = $product[‘brand_id’];
$brands = Brands::get($brand_id);
$brand = $brands[0];
276
Chapter 14: Case Study: Building an E-Commerce Store
c14.qxd:c14 10:46 276


JavaScript Editor Ajax software     Free javascripts