Prev | Current Page 175 | Next

Emilian Balanescu and Cristian Darie

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

These lines configure the plug-in folders used by Smarty. The first one is for the internal
Smarty plug-ins, and the second specifies the smarty_plugins folder you??™ll create to hold the plug-ins
you??™ll write for TShirtShop.
/* Class that extends Smarty, used to process and display Smarty
files */
classApplication extends Smarty
{
// Class constructor
public function __construct()
{
// Call Smarty's constructor
parent::Smarty();
// Change the default template directories
$this->template_dir = TEMPLATE_DIR;
$this->compile_dir = COMPILE_DIR;
$this->config_dir = CONFIG_DIR;
$this->plugins_dir[0] = SMARTY_DIR . 'plugins';
$this->plugins_dir[1] = PRESENTATION_DIR . 'smarty_plugins';
}
}
3. Now, create the Smarty template file for the departments_list componentized template. Write the following
lines in presentation/templates/departments_list.tpl. This will create the presentation
or visual layout of the departments list.
{* departments_list.tpl *}
{load_presentation_object filename="departments_list" assign="obj"}
{* Start departments list *}

Choose a Department



    {* Loop through the list of departments *}
    {section name=i loop=$obj->mDepartments}
    {assign var=selected value=""}
    {* Verify if the department is selected to decide what CSS style
    to use *}
    {if ($obj->mSelectedDepartment ==
    CHAPTER 4 ?–  CREATING THE PRODUCT CATALOG: PART 1 102
    $obj->mDepartments[i].


    Pages:
    163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187