Drupal 7 HTMLPurifier自定义筛选器配置

Drupal 7 HTMLPurifier自定义筛选器配置,drupal-7,htmlpurifier,Drupal 7,Htmlpurifier,我在不同的网站上看到过很多关于添加“到你的HTML净化器配置”的帖子,比如Sonny对这个问题的出色回答: 然而,尽管我可能会尝试,我似乎无法确切地发现如何设置我的HTML净化器配置。实际上,我正试图为la Sonny的评论添加一个自定义过滤器,但我最接近于发现如何在Drupal 7环境中设置HTML净化器配置的地方是/sites/all/modules/htmlpurifier/config/sample.php: <?php /** * @file * This file is

我在不同的网站上看到过很多关于添加“到你的HTML净化器配置”的帖子,比如Sonny对这个问题的出色回答:

然而,尽管我可能会尝试,我似乎无法确切地发现如何设置我的HTML净化器配置。实际上,我正试图为la 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净化器库,如INSTALL.txt文件所示。如果安装正确,状态报告页面将显示版本

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

function htmlpurifier_config_filtered_html($config) {
上面教程的其余部分对我有用,现在我的preFilter和postFilter函数正在被调用


我以为你可以通过用户界面来完成这项工作,但看起来“过滤器”自定义配置框的计算结果不是PHP。

谢谢你的快速响应,克里斯!我已经安装了HTML过滤器,并且运行得很好,事实证明它正在过滤我的YouTube嵌入:-)如果你查看我提供的链接并查看Sonny的回复,你会看到他提到“将以下内容添加到你的HTML净化器配置:”
code
$config->set('Filter.Custom',array(新的HTMLPurifier_Filter_MyIframe());
code
我尝试将该行添加到“HTML净化器(高级)”的过滤器部分Drupal管理面板中的设置,但这导致HTML净化器出现PHP错误,因此我认为这不是添加该语句的正确位置。此外,我刚刚确认状态报告页面显示我已安装了4.4.0版HTML净化器,没有报告问题。此外,我还能够向允许HTML的部分添加标记在UI中为HTML净化器(advanced)设置一个配置,然后这些标记就被允许了,所以我可以毫无问题地完成这项工作。好的,“Filter”标题下的“Custom”文本区域应该完成$config->set('Filter.Custom'…所以在该框中,尝试粘贴Array(new HTMLPurifier\u Filter\u MyIframe());单击字段标签以查看该字段的帮助。它表示该字段应为数组。