php 创建用于模板的smarty函数

izkcnapc  于 2023-05-05  发布在  PHP
关注(0)|答案(1)|浏览(208)

在我的模板中创建一个函数的非常简单的例子中遇到了麻烦。我希望最后能用它来为菜单获取数据。
我对这个例子做了一些改动,但这只是为了让它工作。我在plugins目录中创建了一个function.load_ticker.php文件(甚至使用了getPluginsDir()来确保路径正确)

function smarty_function_load_ticker($params, $smarty)
{
  // assign template variable
  $smarty->assign('test', '123');
}

在shortcenter.tpl文件中,我有

{load_ticker} {$test}

然后我得到很多以下的。。
数组([0]=〉/var/www/html/my_app/vendor/smarty/smarty/libs/plugins/)#0__my_app_autoload(Smarty_Internal_Compile_Load_Ticker)#1 spl_autoload_call(Smarty_Internal_Compile_Load_Ticker)#2 class_exists(Smarty_Internal_Compile_Load_Ticker)在[/var/www/html/my_app/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase. php:[/var/www/html/my_app/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase]. php:[/var/www/html/my_app/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase. html/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/sphp:[/var/www/html/my_app/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase. html/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/software/sphp:[/var/www/html/my_app/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser. html] [/var/www/html/my_app/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser. html] php:[/var/www/html/my_app/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser. php:[/var/www/html/my_app/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser]#8 Smarty_Internal_Templateparser-〉yy_reduce(12)在[/var/www/html/my_app/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser. php:[/var/www/html/my_app/vendor/smarty/smarty/libs/sysplugins/smarty_internal_smartytemplatecompiler. php:#10 Smarty_Internal_SmartyTemplateCompiler-〉doCompile({include file =" sidebar. tpl "} {load_tickker} {$test}
我的smarty版本是4.3.0,我的php版本是7.2(我知道这是旧的,也许这就是问题所在?))
有什么建议吗?
谢谢

j5fpnvbx

j5fpnvbx1#

啊-搞定了。有一个autoload.php文件做了一些有趣的事情。

相关问题