Tpl 在 prestashop 中直接打印 html?

Tpl direct print html in prestashop?

我创建了一个用于在产品后台添加文本区域的自定义模块。当我在 print direct html link this

中打印 tpl 文件中的这个文本区域时

我用它在 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}