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:
- copy and paste aggregator folder from
/modulesto/sites/all/modules - rename all instances of “aggregator” in filenames and body text of each file to “mymod”
- 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_tablemymod_itemwith the additional$itemdata supplied in the mRSS feedmymod.parser.inc: add new elements tofunction reel_parse_feedin theforeach ($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
$itemvariables match up to names retrieved from XMLmymod.processor.inc: to add these parsed variables to thefunction 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(); }
- enable the new
mymodmodule fromadmin/modules, clear cache fromadmin/config/development/performance, run update.php… - Add feeds with success at
admin/config/services/mymod/. Add categories, delete them. - 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
I only create a new module,
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...