Prev | Current Page 260 | Next

Emilian Balanescu and Cristian Darie

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


// Class constructor
public function __construct()
{
...
...
CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 170
if ($this->mPage < 1)
trigger_error('Incorrect Page value');
// Save page request for continue shopping functionality
$_SESSION['link_to_continue_shopping'] = $_SERVER['QUERY_STRING'];
}
6. Modify presentation/departments_list.php by adding the highlighted code, which is also required
for the Continue Shopping functionality:
// 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']);
if (array_key_exists('DepartmentId', $continue_shopping))
$this->mSelectedDepartment =
(int)$continue_shopping['DepartmentId'];
}
}
7. Modify presentation/categories_list.php to load the department ID and category ID parameters
from the Continue Shopping data saved in the session:
// Constructor reads query string parameter
public function __construct()
{
if (!isset($_GET['ProductId']))
{
if (isset ($_GET['DepartmentId']))
$this->mSelectedDepartment = (int)$_GET['DepartmentId'];
else
trigger_error('DepartmentId not set');
if (isset ($_GET['CategoryId']))
$this->mSelectedCategory = (int)$_GET['CategoryId'];
}
CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 171
else
{
$continue_shopping =
Link::QueryStringToArray($_SESSION['link_to_continue_shopping']);
if (array_key_exists('DepartmentId', $continue_shopping))
$this->mSelectedDepartment =
(int)$continue_shopping['DepartmentId'];
else
trigger_error('DepartmentId not set');
if (array_key_exists('CategoryId', $continue_shopping))
$this->mSelectedCategory =
(int)$continue_shopping['CategoryId'];
}
}
8.


Pages:
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272
regeneracja tonerów mapa gify Projekty domów Paradise Poker poker online