Drupal 聚合器输入格式

发布于 2024-07-10 12:40:09 字数 369 浏览 5 评论 0原文

Drupal Aggregator 核心模块是一个有用的模块,但存在许多问题。 有很多人谈论在 Drupal 7 中改进它。

现在我正在使用 Drupal 6 附带的 Aggregator 模块。我正在构建一个聚合站点,但有一个大问题。 有时提要包含 HTML 标签属性(例如 style、dir、title),但聚合器的输入格式过滤器会忽略某些属性(例如 style 和 dir)并允许其他属性(class 和 href)。 如果没有某些属性,提要看起来就很糟糕。 聚合器包含它自己的输入格式,它不使用其他输入格式(这使问题变得更加困难!)。

问题是如何允许某些 HTML 标记的属性出现在提要中。

PS最后要做的是修改Aggregator的核心文件

Drupal Aggregator core module is a useful one but suffers many problems. There are many talking about improving it in Drupal 7.

Right now I'm using Aggregator module which comes with Drupal 6. I'm building an aggregation site, and there is one BIG problem. Sometimes feeds contain HTML tags attributes (e.g. style, dir, title), but Aggregator's input format filter ignores SOME attributes (e.g. style and dir) and allows others (class and href). Without some attributes feeds look very missy. Aggregator contains it's own input format, it doesn't use other inputs formats (and this makes the problem harder!).

The question is how can I allow some HTML tags' attributes to appear in feeds.

P.S. last thing to do is modifying Aggregator's core files

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

梓梦 2024-07-17 12:40:09

您可能需要考虑转向基于 FeedAPI

http://drupal.org/node 构建的较新解决方案之一/326601

正如您从那里开始看到的,这就是聚合方面的操作所在。

You might want to consider moving to one of the newer solutions built on top of FeedAPI

http://drupal.org/node/326601

As you can see starting from there, this is where the action is, aggregation-wise.

烙印 2024-07-17 12:40:09

转到 FeedAPI。 唯一的缺点是没有针对不同提要的立即块。 但是,可以使用节点块进行设置,并在提要项的提要节点中嵌入视图,这还允许您使用视图和 feedapi 映射器来确定每个提要中显示哪些信息。

对于任何繁重的提要工作来说,聚合器只是一个糟糕的模块。 它不提供灵活性,并且不能很好地与视图配合使用。 如果您真的想构建整个站点进行聚合,请切换到 feedapi,然后使用视图来控制可从提要创建的节点的显示。

这需要预先做一些工作,但从长远来看,您将省去尝试寻找可能不存在的神秘提要聚合器解决方案的麻烦。

Move to FeedAPI. The only disadvantage to this is not having immediate blocks for different feeds. However, it's possible to set these up using nodeblock and embedding a view in the feed node of the feed items, which also allows you to use Views and feedapi mapper to determine which information is displayed in each feed.

Aggregator is just a bad module for any heavy lifting with feeds. It offers no flexibility, and doesn't play nicely with Views. If you're serious about building an entire site for aggregation, switch to feedapi, and then use views to control the display of the nodes that can be created from the feeds.

It will take some work up front, but in the long run, you will save yourself the headache of trying to find the mystical feed aggregator solution that likely does not exist.

若相惜即相离 2024-07-17 12:40:09

我早已放弃了 Aggregator,但我鼓励您深入研究源代码,看看问题出在哪里。 大多数核心模块的代码都有很好的文档记录,这是了解模块实际工作原理的最简单方法。

我的猜测是,它要么使用硬编码的标签字符串来允许,要么搭载过滤的 HTML 输入格式。

I long since ditched Aggregator, but I would encourage you to dig into the source to see what the problem is. The code of most core modules are pretty well documented and it''s the easiest way to see how the module actually works.

My guess is that it is either using a hardcoded string of tags to allow, or it is piggybacking on the Filtered HTML input format.

池木 2024-07-17 12:40:09

简短而简单。
查看函数 aggregator_filter_xss() 位于 http://api.drupal.org/api/函数/aggregator_filter_xss

<?php
function aggregator_filter_xss($value) {
  return filter_xss($value, preg_split('/\s+|<|>/', variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'), -1, PREG_SPLIT_NO_EMPTY));
}
?>

正如您所看到的,有一个名为aggregator_allowed_html_tags 的drupal 变量。

您只需在其中一个模块的设置表单上使其可编辑。 因为我没有找到哪个 drupal 管理页面允许编辑这个变量,所以我想说没有。

以下是您的自定义模块所需的代码:

function your_module_settings()
{
    $form = array();

    // Params para aggregator
    $form['aggregator_allowed_html_tags'] = array(
        '#type'          => 'textarea',
        '#title'         => t('Core Module Aggregator allowed tags'),
        '#default_value' => variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'),
        '#required'      => TRUE,
        '#description'   => t('Core Module Aggregator allowed tags'),
    );

    return system_settings_form($form);
}

function your_module_menu()
{
    $items = array();

    $items['admin/content/your-module'] = array(
        'title'            => 'My module settings',
        'description'      => 'desc',
        'page callback'    => 'drupal_get_form',
        'page arguments'   => array('your_module_ pasos'),
        'type'             => MENU_NORMAL_ITEM,
    );

    return $items;
}

希望对您有所帮助。

Short and simple.
Have a look at the function aggregator_filter_xss() at http://api.drupal.org/api/function/aggregator_filter_xss.

<?php
function aggregator_filter_xss($value) {
  return filter_xss($value, preg_split('/\s+|<|>/', variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'), -1, PREG_SPLIT_NO_EMPTY));
}
?>

As you can see there's a drupal variable called aggregator_allowed_html_tags.

You only need to make it editable on a settings form from one of your modules. Since I didn't found which drupal administration page allows to edit this variable, and I would say that there isn't.

Here's the code you will need for your custom module:

function your_module_settings()
{
    $form = array();

    // Params para aggregator
    $form['aggregator_allowed_html_tags'] = array(
        '#type'          => 'textarea',
        '#title'         => t('Core Module Aggregator allowed tags'),
        '#default_value' => variable_get('aggregator_allowed_html_tags', '<a> <b> <br> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>'),
        '#required'      => TRUE,
        '#description'   => t('Core Module Aggregator allowed tags'),
    );

    return system_settings_form($form);
}

function your_module_menu()
{
    $items = array();

    $items['admin/content/your-module'] = array(
        'title'            => 'My module settings',
        'description'      => 'desc',
        'page callback'    => 'drupal_get_form',
        'page arguments'   => array('your_module_ pasos'),
        'type'             => MENU_NORMAL_ITEM,
    );

    return $items;
}

I Hope it's helpful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文