Prev | Current Page 245 | Next

Emilian Balanescu and Cristian Darie

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


'&CategoryId=' . $categoryId;
return self::Build($link);self::Build($link);
}
4. Modify presentation/store_front.php like this:
class StoreFront
{
public $mSiteUrl;
// Define the template file for the page contents
public $mContentsCell = 'blank.tpl';
// Define the template file for the categories cell
public $mCategoriesCell = 'blank.tpl';
// Class constructor
public function __construct()
{
$this->mSiteUrl = Link::Build('');
}
// Initialize presentation object
public function init()
{
// Load department details if visiting a department
if (isset ($_GET['DepartmentId']))
{
CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 154
$this->mContentsCell = 'department.tpl';
$this->mCategoriesCell = 'categories_list.tpl';
}
}
}
?>
5. Now include the categories_list componentized template in presentation/templates/store_front.tpl
just below the list of departments. Note that we include $obj->mCategoriesCell and not categories_
list.tpl, because the list of categories needs to show up only when a department is selected. When no
department is selected, $obj->mCategoriesCell is set to blank.tpl in store_front.php.
{include file="departments_list.tpl"}
{include file=$obj->mCategoriesCell}
6. Load TShirtShop in a web browser. When the page loads, click one of the departments. You??™ll see the categories
list appear in the chosen place.


Pages:
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257