Prev | Current Page 238 | Next

Emilian Balanescu and Cristian Darie

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

Now, let??™s modify presentation/templates/store_front.tpl and presentation/store_front.php
to load the newly created componentized template when DepartmentId appears in the query string. If the
visitor is browsing a department, you set the $mContentsCell member in the StoreFront presentation
object to the componentized template you have just created so that the products you??™ve chosen to display
on the store front appear.
Modify presentation/store_front.php as shown:
class StoreFront
{
public $mSiteUrl;
// Define the template file for the page contents
public $mContentsCell = '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']))
{
$this->mContentsCell = 'department.tpl';
}
}
}
?>
6. Open presentation/templates/store_front.tpl, and replace the text Place contents here with
{include file=$obj->mContentsCell}
7. Load your web site in a browser, and select one of the departments to ensure everything works as expected,
as shown earlier in Figure 5-8.
CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 149
?– Caution Certain versions of PHP 5 have a bug that generates an error when loading the site at this stage,
which reads ???General error: 2014 Cannot execute queries while other unbuffered queries are active.


Pages:
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250