duanchi5078 2016-04-25 16:57
浏览 56
已采纳

Smarty:调用未知方法'显示'

this must be a very stupid question, but i have been searching it's answer and can't find the problem... I've got some trouble while trying to display a smarty template, i was using an older version of smarty and everything worked fine, yet i updated to smarty 3 and i got an exception, it's message saying:

Call of unknown method 'display'.

This is my code:

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();
}

I've been investigating, and all i know until now is the existence of a smarty method: testInstall() Which gives the following info:

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.

I've separated the only FAILED i've got from the rest. It seems libs/sysplugins folder is missing some php files, but downloading it all over again from smarty releases, just gives the same files i have...

To install it, i just copy libs folder into my project, inside "smarty" folder.

Hope to get some help :/

  • 写回答

1条回答 默认 最新

  • dqf67993 2016-04-25 17:21
    关注

    I knew it was a stupid question... by reinstalling smarty 3 it all worked, you see, it seems there was a problem with tortoiseSVN which (who knows why) didn't upload all smarty files properly the first time.

    Strange though, that the files missing weren't the ones testInstall() was talking about...

    Anyway, if any of you guys have the same problem, try reinstalling smarty first.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c