1

我在各个网站上看到了很多关于添加“到您的 HTML Purifier 配置”的帖子,例如 Sonny 对这个问题的出色回答:HTMLPurifier iframe Vimeo 和 Youtube 视频

然而,尽我所能,我似乎无法确切地发现如何设置我的 HTML Purifier 配置。我实际上是在尝试按照 Sonny 的评论添加自定义过滤器但我最接近的发现如何在我的 Drupal 7 环境中设置我的 HTML 净化器配置来自 /sites/all/modules/htmlpurifier/config/sample .php:

<?php

/**
 * @file
 * This file is a sample advanced PHP configuration file for the HTML Purifier
 * filter module. In reality, this file would be named N.php, where N is the
 * integer identifying the filter this is configuring. The configure page
 * for HTML Purifier (advanced) will tell you what file to copy this to.
 *
 * See this URI:
 *
 *    http://htmlpurifier.org/live/configdoc/plain.html
 *
 * For full information about permitted directives. The most interesting ones
 * for custom configuration are ones with the 'mixed' type, as they cannot
 * be configured using the webform.

但这根本没有帮助我 - 我在 HTML Purifier(高级)配置页面(在文本过滤器配置页面上?我没有看到任何东西......)上没有看到任何内容,并且在上面的 URI 也没有帮助。

编辑:非常感谢@Chris 对我最初的问题的回答。后来我发现创建filtered_html.php 文件让我无法从UI 中为过滤后的HTML 配置HTML Purifier!这应该发生吗?

在查看 HTML Purifier (Advanced) 时,我从 UI 中看到的只是“显示帮助文本”复选框。(我已经在下面添加了这个作为评论,但我想我也会修改我的问题,希望更多的人会看到这个......)

4

1 回答 1

0

首先,确保您已安装 HTML 净化器库,如 INSTALL.txt 文件中所示。如果安装正确,状态报告页面将显示版本。

在 Drupal 7 中,过滤器系统现在使用字符串键而不是整数。因此,要在sites/all/modules/htmlpurifier/config/下创建格式为“Filtered HTML”的配置文件,请将sample.php复制到filtered_html.php,并像这样更新钩子函数名称:

function htmlpurifier_config_filtered_html($config) {

上面教程的其余部分对我有用,现在我的 preFilter 和 postFilter 函数正在被调用。

我认为您可以通过 UI 执行此操作,但看起来“过滤器”自定义配置框未评估为 PHP。

于 2012-10-27T20:04:17.450 回答