unknown tag “l” in smarty prestashop

2019-08-06 10:45发布

问题:

We are developing a module in prestashop. At a place, we need to define new smarty object to create and fetch new template. This is working fine but when we using language variable in that custom smarty template then its giving us error for unknown tag "l" in tpl file. Below are code in which we are getting error:

In module controller:

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

In mymodule.tpl:

<div>  
   {$temp|escape:''}
</div> 

In information.tpl:

<span class="kblabel ">{l s='Name' mod='mymodule'}</span><em>*</em>

Now the system is giving us following error

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".