tpl在prestashop中直接打印html吗?

问题描述:

我制作了一个自定义模块,用于在产品后台添加textarea。当我在打印直接的HTML链接打印此textarea的在第三方物流文件这个tpl在prestashop中直接打印html吗?

enter image description here

我使用它来在TPL

{if isset($belvg_textarea)} 
    <div> 
    {$belvg_textarea|unescape:'html'} 
    {$belvg_textarea|escape:'html'} 
    </div> 
{/if} 

打印和显示该模块PHP文件

public function hookDisplayFooterProduct($params) { 
    $id_product = Tools::getValue('id_product'); 
    $sampleObj = Belvg_Sample::loadByIdProduct($id_product); 
    if(!empty($sampleObj) && isset($sampleObj->id)){ 
     $this->context->smarty->assign(array(
      'belvg_textarea' => $sampleObj->textarea, 
     )); 
    } 

    return $this->display(__FILE__, 'views/frontend/sample.tpl'); 
} 

您应该使用nofilter由于prestashop 1.7默认情况下会转义html,因此您的html标记将会显示

在您的TPL文件:

{if isset($belvg_textarea)} 
    <div> 
    {$belvg_textarea nofilter} 
    </div> 
{/if} 
+0

三江源。有用 。 –

+0

不客气! –