tags:

views:

85

answers:

7

I just moved my website to another server and i got this error message using smarty template

http://bit.ly/5MZu2A

Here is part of the smarty file:

/**
 * DIR_SEP isn't used anymore, but third party apps might
 */
if(!defined('DIR_SEP')) {
    define('DIR_SEP', DIRECTORY_SEPARATOR);
}

/**
 * set SMARTY_DIR to absolute path to Smarty library files.
 * if not defined, include_path will be used. Sets SMARTY_DIR only if user
 * application has not already defined it.
 */

if (!defined('SMARTY_DIR')) {
    define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
}

if (!defined('SMARTY_CORE_DIR')) {
    define('SMARTY_CORE_DIR', SMARTY_DIR . 'internals' . DIRECTORY_SEPARATOR);
}

define('SMARTY_PHP_PASSTHRU',   0);
define('SMARTY_PHP_QUOTE',      1);
define('SMARTY_PHP_REMOVE',     2);
define('SMARTY_PHP_ALLOW',      3);

/**
 * @package Smarty
 */
class Smarty
{
    /**#@+
     * Smarty Configuration Section
     */

    /**
     * The name of the directory where templates are located.
     *
     * @var string
     */
    var $template_dir    =  'templates';

    /**
     * The directory where compiled templates are located.
     *
     * @var string
     */
    var $compile_dir     =  'templates_c';

    /**
     * The directory where config files are located.
     *
     * @var string
     */
    var $config_dir      =  'configs';

    /**
     * An array of directories searched for plugins.
     *
     * @var array
     */
    var $plugins_dir     =  array('plugins');

And here is the path of my website and smarty file respectively

/home/cd/public_html

/home/cd/public_html/smarty/Smarty.class.php 
A: 

You should post the PHP code where you sey up the smarty object - where you should declare paths if different from default.

This works fine for me:

$smarty = new Smarty;
$smarty->template_dir = "./templates" ;
$smarty->compile_dir = "./templates_c" ;
$smarty->cache_dir = "./cache" ;
$smarty->config_dir = "./includes";

where the path to said folders is relative to the calling script, even if you keep it in an included file.

djn
Also, make sure folder and template file do really exist there and are readable.
djn
the file permissions are set properly i have checked this so many times and that is not the problemi think the problem is in the path.
grant tailor
A: 

i can see there is a difference in our code? at least not exactly the same so it is better if i you can can help me point to what i should change.

okay the path my website files are located here (just as the error message says):

/home/cd/public_html/ 

and smarty file is located here

/home/cd/public_html/smarty/Smarty.class.php

template and template_c folders are here:

home/cd/public_html/themes/default/templates 

/home/cd/public_html/themes/default/templates_c 

smarty folder is here:

/home/cd/public_html/smarty

Also if you look at the website you can see the path, at least it knows the path of the smarty right? http://bit.ly/5MZu2A

Part of the smarty class file:

if(!defined('DIR_SEP')) {
    define('DIR_SEP', DIRECTORY_SEPARATOR);
}

if (!defined('SMARTY_DIR')) {
    define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
}

if (!defined('SMARTY_CORE_DIR')) {
    define('SMARTY_CORE_DIR', SMARTY_DIR . 'internals' . DIRECTORY_SEPARATOR);
}

define('SMARTY_PHP_PASSTHRU',   0);
define('SMARTY_PHP_QUOTE',      1);
define('SMARTY_PHP_REMOVE',     2);
define('SMARTY_PHP_ALLOW',      3);

class Smarty
{
    /**#@+
     * Smarty Configuration Section
     */

    /**
     * The name of the directory where templates are located.
     *
     * @var string
     */
    var $template_dir    =  'templates';

    /**
     * The directory where compiled templates are located.
     *
     * @var string
     */
    var $compile_dir     =  'templates_c';

    /**
     * The directory where config files are located.
     *
     * @var string
     */
    var $config_dir      =  'configs';

    /**
     * An array of directories searched for plugins.
     *
     * @var array
     */
    var $plugins_dir     =  array('plugins');
grant tailor
A: 

Absolute paths should be error-proof, I guess:

require '/home/cd/public_html/smarty/Smarty.class.php';
$smarty = new Smarty;
$smarty->template_dir = "/home/cd/public_html/themes/default/templates" ;
$smarty->compile_dir = "/home/cd/public_html/themes/default/templates_c" ;
$smarty->cache_dir = "/home/cd/public_html/themes/default/cache" ;
$smarty->config_dir = "/home/cd/public_html/themes/default/includes";

as long as you have a cache and an include folder there (you may change their names freely, or put them elsewhere). Add this while working out the hitches:

$smarty->debugging = true;

to send a complete listing of smarty variables to a pop-up page (you might have to allow this in your browser's pop-up blocker).

djn
A: 

Where do i add this code?

Also u see you are using

$smarty->template_dir

And i am using

var $template_dir   

So what need to be added, and where?

Thanks a lot really appreciate it; can't believe there is no one else to help with this.

grant tailor
A: 

You don't have to change Smarty.class.php at all. You probably have a declaration like $smarty = new Smarty() in your index.php where you should find the $smarty->template_dir = "path_to_your_dir";.

Zsolti
A: 

I thought i needed to edit the Smarty.class.php file, i thouhgt thats where i should add or change the code.

I have searched for an Index.php file but didn't find anything related to $smarty

grant tailor
Since the error you get is a Smarty error it's pretty sure a Smarty object has been somewhere instantiated. It may well be called something other than $smarty (my personal favorite is the shorter $tpl) - look for a line with 'new Smarty'. Better still, serch for any line with a 'new' something, as the called object might also be a subclass of Smarty, i.e. a differently named object that extends the basic Smarty and inherits its proprieties nad methods. Take a peek at every included or required file too.
djn
A: 

I fixed it, at least my hosting company did

The problem was from the database, smarty was using the previous path from the other hosting company i moved from so i needed to update the path.

Thanks!

grant tailor