Smarty:调用未知方法 'display'

Smarty: Call of unknown method 'display'

这一定是一个非常愚蠢的问题,但我一直在寻找它的答案,但找不到问题...我在尝试显示 smarty 模板时遇到了一些麻烦,我使用的是旧版本smarty 的,一切正常,但我更新到 smarty 3 时出现异常,消息说:

Call of unknown method 'display'.

这是我的代码:

Index.php

require_once './GeneralFunctions.php';

$smartyVariables = getSmartyVariablesToAssign();
tryToDisplaySmartyTemplate('Index.tpl', $smartyVariables);

function getSmartyVariablesToAssign() {
    $userAndOrPasswordError = $_GET['userAndOrPasswordError'];
    return array(
        'userAndOrPasswordError' => $userAndOrPasswordError
    );
}

GeneralFunctions.php

require_once './smarty/libs/Smarty.class.php';

function tryToDisplaySmartyTemplate($templateName, $variablesToAssign = null) {
    try {
        $mySmarty = callSmarty();
        assignSmartyVariables($mySmarty, $variablesToAssign);
        $mySmarty->display($templateName);
    } catch (Exception $exc) {
        showCatchedExceptionTraceAndMessage($exc);
    }
}

function callSmarty() {
    $mySmarty = new Smarty();
    $mySmarty->template_dir = 'smarty/templates';
    $mySmarty->compile_dir = 'smarty/templates_c';
    $mySmarty->config_dir = 'smarty/config';
    $mySmarty->cache_dir = 'smarty/cache';
    return $mySmarty;
}

function assignSmartyVariables($mySmarty, $variablesToAssign) {
    foreach ($variablesToAssign as $key => $value) {
        $mySmarty->assign($key, $value);
    }
}

function showCatchedExceptionTraceAndMessage(Exception $exc) {
    echo "Ocurrió un error desconocido, por favor, notifique al departamento de sistemas.",
    "<br>",
    "<br>",
    $exc->getTraceAsString(),
    "<br>",
    "<br>",
    $exc->getMessage();
}

我一直在调查,直到现在我所知道的是存在一个聪明的方法:testInstall() 其中提供了以下信息:

Smarty Installation test... Testing template directory... C:\xampp\htdocs\develop\Registro_de_Tramites\smarty\templates is OK. Testing compile directory... C:\xampp\htdocs\develop\Registro_de_Tramites\smarty\templates_c is OK. Testing plugins directory... C:\xampp\htdocs\develop\Registro_de_Tramites\smarty\libs\plugins is OK. Testing cache directory... C:\xampp\htdocs\develop\Registro_de_Tramites\smarty\cache is OK. Testing configs directory... C:\xampp\htdocs\develop\Registro_de_Tramites\smarty\config is OK.

Testing sysplugin files... FAILED: files missing from libs/sysplugins: smarty_internal_extension_codeframe.php, smarty_internal_extension_config.php, smarty_internal_extension_defaulttemplatehandler.php, smarty_internal_filter_handler.php, smarty_internal_function_call_handler.php, smarty_internal_get_include_path.php.

Testing plugin files... ... OK Tests complete.

我已经把我唯一的失败与其他失败分开了。似乎 libs/sysplugins 文件夹缺少一些 php 文件,但是从 smarty releases 重新下载它,只是给出了我拥有的相同文件...

要安装它,我只需将 libs 文件夹复制到我的项目中,在“smarty”文件夹中。

希望得到一些帮助:/

我知道这是一个愚蠢的问题...通过重新安装 smarty 3 一切正常,你看,似乎 tortoiseSVN 有问题,(谁知道为什么)第一次没有正确上传所有 smarty 文件时间.

奇怪的是,丢失的文件不是 testInstall() 正在谈论的文件...

无论如何,如果你们中的任何人遇到同样的问题,请先尝试重新安装 smarty。