“未知标签”;l";在smarty prestashop
我们正在prestashop开发一个模块。在某个地方,我们需要定义新的smarty对象来创建和获取新模板。这工作正常,但当我们在自定义smarty模板中使用语言变量时,tpl文件中的未知标记“l”会给我们带来错误。下面是出现错误的代码: 在模块控制器中:“未知标签”;l";在smarty prestashop,smarty,prestashop,Smarty,Prestashop,我们正在prestashop开发一个模块。在某个地方,我们需要定义新的smarty对象来创建和获取新模板。这工作正常,但当我们在自定义smarty模板中使用语言变量时,tpl文件中的未知标记“l”会给我们带来错误。下面是出现错误的代码: 在模块控制器中: class MymoduleTestModuleFrontController extends ModuleFrontController { function initContent(){ $this->c
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>
{$temp |转义:“”
在information.tpl中:
<span class="kblabel ">{l s='Name' mod='mymodule'}</span><em>*</em>
{l s='Name'mod='mymodule'}*
现在系统给了我们以下错误
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".
致命错误:未捕获-->Smarty编译器:模板中的语法错误“/var/www/html/prestashop/modules/mymodule/views/templates/front/product/informations.tpl”第12行“{l s='Name'mod='mymodule'}*”未知标记“l”是否尝试使用{literal}标记进行测试?谢谢你的回复。不,这里的“l”不代表文字,它用于将语言翻译放入模板文件中。请尝试使用new SmartyCustom()代码>-PrestaShop目录中不存在由PrestaShop Core devsSmartyCustom类扩展的。是否尝试使用{literal}标记进行测试?谢谢你的回复。不,这里的“l”不代表文字,它用于将语言翻译放入模板文件中。请尝试使用new SmartyCustom()代码>-PrestaShop目录中不存在由PrestaShop Core devsSmartyCustom类扩展的。