I’m attempting to customize Drupal 7’s core Aggregator module in order to parse and process $item data from an mRSS feed.

Please, no Feeds

Forum and doc chatter I’ve trolled through resolve most users’ needs by pointing to Feeds + xPath Parser to get the job done. These modules are great, and I’ll join in the buzz to endorse their ease of use — I was able to quickly and successfully set them up to parse and map my custom feed variables.

However, for my purposes, I’ll prefer Aggregator’s non-node-creating approach to syndication. So, responses specifically geared to customizing Aggregator — not deploying Feeds — will be most appreciated.

Approach

Here’s a detailed breakdown of my approach to-date:

  1. copy and paste aggregator folder from /modules to /sites/all/modules
  2. rename all instances of “aggregator” in filenames and body text of each file to “mymod”
  3. scour the code in all files of the module’s directory for relevant snippets I might need to alter. Set out to modify the following files:
    • mymod.install: to add headings the the db_table mymod_item with the additional $item data supplied in the mRSS feed
    • mymod.parser.inc: add new elements to function reel_parse_feed in the foreach ($items as $item) { by adding new variables in following syntax:
      	if (!empty($item['media:keywords'])) {
      	  $item['media:keywords'] = $item['media:keywords'];
      	}
      	else {
      	  $item['media:keywords'] = '';
      	} 

      where $item variables match up to names retrieved from XML

    • mymod.processor.inc: to add these parsed variables to the function reel_save_item($edit) { fields array, again, adapting to syntax of existing code there:
      function reel_save_item($edit) {
        if ($edit['title'] && empty($edit['iid'])) {
          $edit['iid'] = db_insert('reel_item')
            ->fields(array(
              'title' => $edit['title'],
              'link' => $edit['link'],
              'author' => $edit['author'],
              'description' => $edit['description'],
              'guid' => $edit['guid'],
              'timestamp' => $edit['timestamp'],
              'fid' => $edit['fid'],
              'media:keywords' => $edit['media:keywords'],
            ))
            ->execute();
        }
      
  4. enable the new mymod module from admin/modules, clear cache from admin/config/development/performance, run update.php…
  5. Add feeds with success at admin/config/services/mymod/. Add categories, delete them.
  6. receive HTTP Error 500 on attempts to “update items” on that page, or to manually “run cron” from admin/config/system/cron

Finally: a question

I’d love to get any guidance from more experienced Drupal’ers on where I might be going wrong, how to change my approach to generate more precise errors about where my problems might lie, or whether I should throw this out altogether?

Hook approach?

Maybe I should be focussing on better understanding hook_aggregator_parse and hook_aggregator_process at the theme level? Editing template.tpl.php to alter the core Aggregator module? Any helpful walkthroughs available on how to make a custom parser with that approach?

Comments

carcheky’s picture

I create a new module, with only aggregator_customparser.info (drupal:aggregator as dependency) & aggregator_customparser.module (this file, was aggregator.parser.inc with renamed and personaliced functions)

all done!

PD: sorry my english...