I have been tinkering with SMARTY the last few days, and so far have had little problems. I am moderately familiar with the setup and have read through several articles found through Google as well as the documentation provided on the SMARTY website. With that said, I am having some problems with my SMARTY setup.
I posted this question in the SMARTY forums (http://www.phpinsider.com/smarty-for...?p=51778#51778), but so far no one has been able to help
The error in question is:
Fatal error: Call to a member function assign() on a non-object in /Users/city.php on line 41
// include configuration files
// get action
$action = strip_tags($_GET['action']);
// add new city
if($action == 'add')
$smarty -> assign('sub_title', 'Add City');
$smarty -> display('pages/city_add.tpl');
// modify existing city
else if($action == 'modify')
$smarty -> assign('sub_title', 'Modify City');
$smarty -> display('pages/city_modify.tpl');
// remove city
else if($action == 'remove')
$smarty -> assign('sub_title', 'Remove City');
$smarty -> display('pages/city_remove.tpl');
// show navigation
$smarty -> assign('sub_title', 'City Management');
$smarty -> display('pages/city.tpl');
and the configuration file required:
// include all library files
// setup SMARTY
$smarty = new smarty;
$smarty -> template_dir = 'templates';
$smarty -> compile_dir = 'templates_c';
$smarty -> cache_dir = 'cache';
$smarty -> config_dir = 'configs';
$smarty -> security = true;
I've tried several variations in setting up the smarty resource, but still no good. I added the global $smarty (as I was told to do in the SMARTY forums) and still nothing . . . I even verified that globals where turned on in my php.ini file.
The configuration file is in the correct directory. I verified this multiple times, and even changed the require_once to some arbitrary file name, which produced an error.
I even went as far as to verify that the SMARTY object was being created by doing a print_r($smarty). With and without globals turned on (or specified in the code) it gave the smarty object correctly. So I know the object is being created, and passed from the configuration file.
This is absolutely driving me nuts, any help would be greatly appreciated!