Prev | Current Page 106 | Next

Emilian Balanescu and Cristian Darie

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

In PHP, the
constructor of a class is called __construct(). Writing that code in the constructor of the Application
class guarantees that it gets executed automatically when a new instance of Application is created.
The Smarty template file (store_front.tpl), except for a few details, contains simple HTML code. Those details
are worth analyzing. In store_front.tpl, before the HTML code begins, the configuration file site.conf is
loaded.
{* smarty *}
{config_load file="site.conf"}
?– Tip Smarty comments are enclosed between {* and *} marks.
At this moment, the only variable set inside the site.conf file is site_title, which contains the name of the
web site. The value of this variable is used to generate the title of the page in the HTML code:
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


{#site_title#}



CHAPTER 3 ?–  STARTING THE TSHIRTSHOP PROJECT 49
Variables that are loaded from the configuration files are referenced by enclosing them within hash marks (#), or
with the smarty variable $smarty.config, as in:

{$smarty.config.site_title}

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118