如何禁用流体局部特殊字符的自动编码(TYPO3)

时间:2014-05-23 12:52:58

标签: typo3 fluid

应该够简单。我试图将输入字段添加到扩展名中的流体部分" yag" (还有另一个画廊)。

输入:<f:form.textfield id="live-filter" name="test" />

输出:&lt;input id=&quot;live-filter&quot; type=&quot;text&quot; name=&quot;test&quot; /&gt;

不知何故,代码会在过程中被过滤掉,但我不知道为什么。 TYPO3 v.6.2

YAG v.3.2.1

编辑:一个疯狂的猜测是TYPO3本身的一些输出过滤,但在哪里?我没有按目的设置任何东西。

3 个答案:

答案 0 :(得分:2)

你需要向上遍历路径以检查是否有任何流体标签缠绕在它周围,这是逃逸的。通常,所有标签都会逃脱。 另请查看<f:render partial...周围的代码。

也可能是调用流体模板的TypoScript代码设置了.htmlspecialchars = 1

答案 1 :(得分:1)

截至TYPO3版本。 9.5及以上10.4您还可以将Fluid模板中的输出包装到<f:format.htmlentitiesDecode>标签中,如下所示:

<f:format.htmlentitiesDecode>
    <f:form.textfield id="live-filter" name="test" />
</f:format.htmlentitiesDecode>

有关此信息的更多信息,in the TYPO3 View Helper Reference.

答案 2 :(得分:0)

TYPO3 8 起,还有另一个陷阱:自定义Viewhelpers会对输出进行htmlspecialchars,除非另有说明。解决方案是:

<?php
namespace Vendor\ArTest\ViewHelpers;

class YourViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper{

  /**
    * As this ViewHelper renders HTML, the output must not be escaped.
    *
    * @var bool
    */
  protected $escapeOutput = false;