Wow! We have a librarian here!
I saw this post after I made my last post. After re-reading the code for the 20th time, I finally see how it works?! (:
Some follow-up questions…
1.) I don’t understand this bolded code…
<?php
// Plug-in functions inside plug-in files must be named: smarty_type_name
function smarty_function_load_presentation_object($params, $smarty)
{
require_once PRESENTATION_DIR . $params['filename'] . '.php';
$className = str_replace(' ', '',
ucfirst(str_replace('_', ' ',
$params['filename'])));
// Create presentation object
$obj = new $className();
[B][COLOR="Blue"] if (method_exists($obj, 'init'))
{
$obj->init();
}
[/COLOR][/B]
// Assign template variable
$smarty->assign($params['assign'], $obj);
}
?>
When would ‘init’ NOT exist??
2.) I don’t understand this bolded code…
<?php
// Plug-in functions inside plug-in files must be named: smarty_type_name
function smarty_function_load_presentation_object($params, $smarty)
{
require_once PRESENTATION_DIR . $params['filename'] . '.php';
$className = str_replace(' ', '',
ucfirst(str_replace('_', ' ',
$params['filename'])));
// Create presentation object
$obj = new $className();
if (method_exists($obj, 'init'))
{
$obj->init();
}
// Assign template variable
[B][COLOR="Blue"] $smarty->assign($params['assign'], $obj);[/COLOR][/B]
}
?>
What are we assigning? To where? And why?
3.) Since you obviously know Smarty, and since you have the same book, what is your advice to me as far as using Smarty and the author’s code to build my first e-commerce site?
I have been speaking to a few people who seem to think that Smarty and this author’s code are making things more difficult than need be.
My goal is to learn how to code this myself, versus “configuring” something like Magento.
I am open to a new approach, as long as it is a complete solution and not just bits and pieces.
TomTees