Помогите пожалуйста с ошибкой шаблона smarty - PullRequest
0 голосов
/ 29 августа 2010

Я только что переместил свой сайт на другой сервер и получил это сообщение об ошибке, используя шаблон smarty

http://bit.ly/5MZu2A

Вот часть файла smarty:

/**
 * 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');

И вот путь моего сайта и файл smarty соответственно

/home/cd/public_html

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

Ответы [ 4 ]

0 голосов
/ 31 августа 2010

Я исправил это, по крайней мере, моя хостинговая компания сделала

Проблема была из базы данных, smarty использовал предыдущий путь от другой хостинговой компании, из которой я переехал, поэтому мне нужно было обновить путь.

Спасибо!

0 голосов
/ 31 августа 2010

Абсолютные пути должны быть защищены от ошибок, я думаю:

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

, если у вас есть папки cache и include (вы можете свободно менять их имена или помещать ихв другом месте).Добавьте это, решая проблемы:

$smarty->debugging = true;

, чтобы отправить полный список переменных smarty на всплывающую страницу (возможно, вам придется разрешить это в блокировщике всплывающих окон вашего браузера).

0 голосов
/ 31 августа 2010

Вам не нужно менять Smarty.class.php.Возможно, у вас есть объявление типа $smarty = new Smarty() в вашем index.php , где вы должны найти $smarty->template_dir = "path_to_your_dir";.

0 голосов
/ 29 августа 2010

Вы должны опубликовать код PHP, где вы находите разумный объект - где вы должны объявить пути, если они отличаются от значений по умолчанию.

Это прекрасно работает для меня:

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

гдепуть к указанным папкам указывается относительно вызывающего скрипта, даже если вы храните его во включенном файле.

...