【问题标题】:Render HTML from PHP array via Smarty通过 Smarty 从 PHP 数组渲染 HTML
【发布时间】:2013-10-14 20:54:43
【问题描述】:

这是 Smarty 模板文件的内容...

{foreach from=$productcustomfields item=customfield}
<tr>
  <td class="fieldarea">{$customfield.name}:</td>
  <td>{$customfield.value}</td>
</tr>
{/foreach}

当 {$customfield.value} 在屏幕上呈现时,来自该数组值的任何 HTML 标记都会在浏览器中显示为纯文本。如何让 Smarty 实际呈现 HTML 标签而不是将它们作为文字文本?

例如,如果 $customfield.value 的值是...

<strong>Hello</strong>

它会在浏览器中显示,而不是应有的 Hello

【问题讨论】:

  • 您的 Smarty 对象上是否有 registerFilter('variable','htmlspecialchars')
  • 我不能确定。此模板文件来自编码和许可软件,因此我无权访问该信息。

标签: php html arrays tags smarty


【解决方案1】:

试试

{$customfield.value nofilter}

(见reference

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-17
    • 2011-04-30
    • 1970-01-01
    • 2019-12-21
    • 2013-09-29
    • 2015-08-31
    • 2014-11-20
    相关资源
    最近更新 更多