php - Please help with smarty template error

127

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 
589

Answer

Solution:

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.

54

Answer

Solution:

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 acache and aninclude 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).

923

Answer

Solution:

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";.

465

Answer

Solution:

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!

People are also looking for solutions to the problem: How can I make my php pagination paginate via Jquery AJAX

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.