Prev | Current Page 173 | Next

Emilian Balanescu and Cristian Darie

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


Smarty plug-in files and functions must follow strict naming conventions to be located
by Smarty. Smarty plug-in files must be named as type.name.php (in our case, function.load_
presentation_object.php), and the functions inside these files must be named as smarty_
type_name (in our case, smarty_function_load_presentation_object). The official page for
Smarty plug-ins naming conventions is http://smarty.php.net/manual/en/plugins.naming.
conventions.php. You can learn more about Smarty plug-ins at http://smarty.php.net/manual/
en/plugins.php.
After the Smarty plug-in file is in place, you can reference it from the Smarty design
template file (departments_list.tpl) with a line like this:
{load_presentation_object filename="departments_list" assign="obj"}
Given the correct naming conventions where used, this line is enough to get Smarty to
load the plug-in file, which at its turn will load the presentation object mentioned through
the filename parameter, and assign the loaded object to a template variable (in our example the
name of the variable will be obj). The Smarty design template file can then access the variables
populated by the plug-in function like this:
{$obj->mDepartments[i].name}
To understand how the whole mechanism works, let??™s create the departments_list componentized
template, and all the other pieces required to have it working.


Pages:
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
OFE akademia kyokushin zasady pokera słownik Wisła noclegi