Prev | Current Page 240 | Next

Emilian Balanescu and Cristian Darie

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

tpl template file is used, since we haven??™t yet implemented the contents cell template (you??™ll
change this when creating a template to populate the contents cell for the first page).
This is the code in store_front.php that assigns a value to $mContentsCell when a department is selected:
// Initialize presentation object
public function init()
{
// Load department details if visiting a department
if (isset ($_GET['DepartmentId']))
{
$this->mContentsCell = 'department.tpl';
}
}
The first interesting aspect to know about department.tpl is the way it loads the Department presentation
object with the help of load_presentation_object Smarty plug-in function.
CHAPTER 5 ?–  CREATING THE PRODUCT CATALOG: PART 2 150
{* department.tpl *}
{load_presentation_object filename="department" assign="obj"}
This allows you to access the instance of the Department class (which we??™ll discuss next) and its public members
($mName and $mDescription) from the template file (department.tpl), like this:

{$obj->mName}


{$obj->mDescription}


Place list of products here
The next step now is to understand how the presentation object, department.php, does its work to obtain
the department??™s name and description. The file contains the Department class. The two public members of
Department are the ones you access from the Smarty template (the department??™s name and description).


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