Emilian Balanescu and Cristian Darie
"Beginning PHP and MySQL E-Commerce: From Novice to Professional, Second Edition"
amazon.com/exec/obidos/ASIN/' .
$this->mProducts[$i]['asin'] . '/ref=nosim/' . AMAZON_ASSOCIATES_ID;
}
}
?>
3. Add the following two configuration lines at the end of your include/config.php file:
// Amazon.com department configuration options
define('AMAZON_DEPARTMENT_TITLE', 'Amazon T-Shirts');
define('AMAZON_DEPARTMENT_DESCRIPTION',
'Browse these wonderful t-shirts that Amazon.com offers');
CHAPTER 22 ?– USING AMAZON.COM WEB SERVICES 683
4. Modify the presentation/templates/departments_list.tpl template file to add the Amazon T-Shirts
department. Add the highlighted code shown here:
{* Generate a link for a new department in the list *}
{$obj->mDepartments[i].name}
{/section}
{assign var=selected value=""}
{if $obj->mAmazonSelected}
{assign var=selected value="class=\"selected\""}
{/if}
{$obj->mAmazonDepartmentName}
{* End departments list *}
5. Update presentation/departments_list.php as highlighted in this code snippet:
// Manages the departments list
class DepartmentsList
{
/* Public variables available in departments_list.tpl Smarty template */
public $mSelectedDepartment = 0;
public $mDepartments;
public $mAmazonSelected = false;
public $mAmazonDepartmentName;
public $mLinkToAmazonDepartment;
// Constructor reads query string parameter
public function __construct()
{
/* If DepartmentId exists in the query string, we're visiting a
department */
if (isset ($_GET['DepartmentId']))
$this->mSelectedDepartment = (int)$_GET['DepartmentId'];
elseif (isset($_GET['ProductId']) &&
isset($_SESSION['link_to_continue_shopping']))
{
$continue_shopping =
Link::QueryStringToArray($_SESSION['link_to_continue_shopping']);
CHAPTER 22 ?– USING AMAZON.
Pages:
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798