Prev | Current Page 71 | Next

Emilian Balanescu and Cristian Darie

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

Its main purpose is to offer you a simple
way to separate application logic (PHP code) from its presentation code (HTML).
This separation permits the programmer and the template designer to work independently
on the same application. The programmer can change the PHP logic without needing to
change the template files, and the designer can change the templates without caring how the
code that makes them alive works.
Figure 2-4 shows the relationship between the Smarty design template file and its Smarty
plug-in file.
CHAPTER 2 ?–  LAYING OUT THE FOUNDATIONS 21
Figure 2-4. Smarty componentized template
The Smarty design template (a .tpl file containing the HTML layout and Smarty-specific
tags and code) and its Smarty plug-in file (a .php file containing the associated code for the
template) form a Smarty componentized template.
In practice, we??™ll not create a Smarty plug-in file for each template, as shown in Figure 2-4.
Instead, we??™ll create a generic Smarty plug-in that integrates with all your Smarty templates,
loading the necessary presentation objects. Presentation objects are classes that provide the
template files with the data they need.
You??™ll learn more about how Smarty works while you??™re building the e-commerce web site.
For a concise introduction to Smarty, read the Smarty Crash Course at http://smarty.php.net/
crashcourse.


Pages:
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83