Jump to content

SMARTY Fatal Error


Louis11

Recommended Posts

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-forum/viewtopic.php?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

 

City.php contains:

<?
// include configuration files
require_once('includes/configuration.php');
   
global $smarty;

// 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
else
{
   $smarty -> assign('sub_title', 'City Management');
   $smarty -> display('pages/city.tpl');
}
?> 

 

and the configuration file required:

<?
// include all library files
require_once('libs/Smarty.class.php');
   
// setup SMARTY
global $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.

 

Any help would be greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/117469-smarty-fatal-error/
Share on other sites

  • 1 month later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.