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
Share on other sites

  • 1 month later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.