我们正在prestashop开发一个模块。在某个地方,我们需要定义新的智能对象来创建和获取新模板。这工作正常,但是当我们在自定义智能模板中使用语言变量时,它会给出我们错误的未知标签" l"在tpl文件中。以下是我们收到错误的代码:
在模块控制器中:
class MymoduleTestModuleFrontController extends ModuleFrontController
{
function initContent(){
$this->context->smarty->assign('temp', $this->test());
$this->setTemplate('mymodule.tpl);
}
function test(){
$custom_smarty = new Smarty();
$custom_smarty->setTemplateDir(_PS_MODULE_DIR_.'mymodule/views/templates/front/product');
$tpl = $custom_smarty->createTemplate('informations.tpl');
return $tpl->fetch();
}
}
在mymodule.tpl中:
<div>
{$temp|escape:''}
</div>
在information.tpl中:
<span class="kblabel ">{l s='Name' mod='mymodule'}</span><em>*</em>
现在系统正在给我们以下错误
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "/var/www/html/prestashop/modules/mymodule/views/templates/front/product/informations.tpl" on line 12 "<span class="kblabel ">{l s='Name' mod='mymodule'}</span><em>*</em>" unknown tag "l" <-- thrown in /var/www/html/prestashop/tools/smarty/sysplugins/smarty_internal_templatecompilerbase.php on line 12
We dont know, why we are getting this error? this error dont comes if we directly put the html of "information.tpl" into "mymodule.tpl".