topical media & game development

talk show tell print

professional-search-14-seophp-product.php / php



  <?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';
  // load the URL redirect library
  require_once 'include/url_redirect.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_category_product_url(proper_url);
  
  // retrieve the brand details 
  brand_id = product['brand_id'];
  brands = Brands::get(brand_id);
  brand = brands[0];
  brand_image_url = make_media_url(brand_id, brand['name'], 'jpg');
  
  // send a 404 if the product or category does not exist
  if  (!product || !category) {
    header("HTTP/1.0 404 Not Found");
    exit();
  }
  ?>
  
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html>
    <head>
      <title><?php echo product['name'] ?> - Cookie Ogre Warehouse</title>
    </head>
    <body>
      <!-- Display title, which includes link to the home page -->
      <h1>
        <?php echo product['name'] ?> - 
        <a href="/">Cookie Ogre Warehouse</a>
      </h1>
  
      <!-- Display the product description -->    
      <p><?php echo product['desc'];?></p>
      
      <!-- Display the brand logo -->    
      <p>
        This cookie is brought to you by <?php echo brand['name']; ?>.
        <br /><img src="<?php echo brand_image_url; ?>"/>
      </p>   
      
      <!-- Display the product price -->
      <p>Price: 
  <?php
  // display price in CAD for canadian visitors, or in USD otherwise
  if (SimpleGeoTarget::isRegion("CA"))
    echo product['price'] * 1.17 . ' CAD';
  else
    echo product['price'] . ' USD';
  ?>    
      </p>
      
      View more products in our 
      <a href="<?php echo category_url; ?>">
        <?php echo category['name']; ?></a>
      category.    
    </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.