2
這裏是我的目錄結構:爲什麼不能Smarty的加載此塊標記插件
./smartytest.php
./smarty31/*(庫等)
./plugins/block.sayhi .PHP
初始化Smarty的PHP代碼是:
require_once('smarty31/libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->template_dir = getcwd() . '/templates';
$smarty->compile_dir = getcwd() . '/templates_c';
$smarty->plugins_dir[] = getcwd() . '/plugins';
該插件的PHP代碼:
<?php
function smarty_block_sayhi($params, $content, $smarty, $open) {
if (!$open) {
return 'Hello: ' . $content;
}
}
?>
該錯誤消息我得到的是這樣的:
Fatal error: Uncaught exception 'SmartyCompilerException' with message 'Syntax Error in template "/mypath/phptests/templates/page.tpl" on line 11 "{sayhi}" unknown tag "sayhi"'
當插件是smarty31 /庫/ plugins目錄下,它加載的罰款。這個示例代碼是否不正確地初始化Smarty?
「/mypath/phptests/templates/page.tpl」的內容是什麼?看起來你有一個無法識別的標籤 – Alex
哇Smarty。這是過去的一次爆炸。人們仍然使用它? – Layke