Я переместил свой сайт на другой сервер, и я получил это сообщение об ошибке с помощью шаблона smarty
Вот часть файла 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
Я исправил его, по крайней мере, моя хостинговая компания сделала
Проблема была в базе данных, smarty использовал предыдущий путь от другой хостинговой компании, из которой я переехал, поэтому мне нужно было обновить путь.
Спасибо!
Вам вообще не нужно менять Smarty.class.php. У вас, вероятно, есть объявление типа $smarty = new Smarty()
в index.php, где вы должны найти $smarty->template_dir = "path_to_your_dir";
.
Абсолютные пути должны быть устойчивыми к ошибкам, я полагаю:
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 на всплывающую страницу (возможно, вам придется разрешить это в блокировщике всплывающих окон вашего браузера).
Вы должны опубликовать PHP-код, где вы заглянете в объект smarty, где вы должны объявлять пути, если они отличаются от стандартных.
Это отлично работает для меня:
$smarty = new Smarty;
$smarty->template_dir = "./templates" ;
$smarty->compile_dir = "./templates_c" ;
$smarty->cache_dir = "./cache" ;
$smarty->config_dir = "./includes";
где путь к указанным папкам относится к вызывающему script, даже если вы храните его во включенном файле.