请帮助解决smarty模板错误

时间:2010-08-29 14:25:46

标签: php mysql 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');

以下是我的网站和智能文件的路径

/home/cd/public_html

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

4 个答案:

答案 0 :(得分:0)

你应该在你发布smarty对象的地方发布PHP代码 - 如果与默认对象不同,你应该声明路径。

这对我来说很好用:

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

其中所述文件夹的路径是相对于调用脚本的,即使您将其保存在包含的文件中也是如此。

答案 1 :(得分:0)

绝对路径应该是防错的,我想:

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

只要您有cacheinclude文件夹(您可以自由更改其名称,或将其放在其他位置)。在解决问题时加上这个:

$smarty->debugging = true;

将完整的智能变量列表发送到弹出页面(您可能必须在浏览器的弹出窗口阻止程序中允许这样做。)

答案 2 :(得分:0)

您根本不需要更改Smarty.class.php。你可能在 index.php 中有$smarty = new Smarty()的声明,你应该找到$smarty->template_dir = "path_to_your_dir";

答案 3 :(得分:0)

我修好了,至少我的托管公司做了

问题来自数据库,smarty正在使用我移动的其他托管公司的上一条路径,所以我需要更新路径。

谢谢!