Prev | Current Page 171 | Next

Emilian Balanescu and Cristian Darie

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

In this case, we??™re calling
GetAll() to retrieve the list of departments.
Right now, the database connection is opened when index.php starts processing and is closed at the end. All
database operations that happen in one iteration of this file will be done through this connection.
Displaying the List of Departments
Now that everything is in place in the other tiers, all you have to do is create the presentation
tier part??”this is the final goal that we??™ve been aiming toward from the beginning of this chapter.
As shown previously, the departments list needs to look something like the one shown in
Figure 4-13 when the site is loaded in the browser.
Figure 4-13. TShirtShop with a dynamically generated list of departments
You??™ll implement this functionality as a separate componentized template named
departments_list. You??™ll then just include departments_list.tpl in the main Smarty template
(templates/store_front.tpl).
The departments_list componentized template is made up of three files: the Smarty
design template (templates/departments_list.tpl), the presentation object (presentation/
departments_list.php), and the Smarty plug-in file (presentation/smarty_plugins/function.
load_presentation_object.php). The Smarty plug-in file is a generic plug-in that will be used
by all Smarty templates to load presentation objects.
CHAPTER 4 ?–  CREATING THE PRODUCT CATALOG: PART 1 99
Using Smarty Plug-ins
The Smarty plug-in is the Smarty technique we??™ll use to implement the logic behind Smarty
design template files (with the .


Pages:
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183