Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top