Is it possible to run one feed importer on several sources?
Currently my code is as follow:
My importer module file is
function myModule_import_feeds_plugins() {
$info = array();
$info['xml_parser'] = array(
'name' => 'XML feed parser',
'description' => 'Imports XML feed.',
'help' => '',
'handler' => array(
'parent' => 'FeedsParser',
'class' => 'myXmlParser',
'file' => 'my_xml_parser.inc',
'path' => drupal_get_path('module', 'myModule_import') . '/plugins/feeds',
),
);
My parser is:
class myXmlParser extends FeedsParser {
/**
* Implements FeedsParser::parse().
*/
public function parse(FeedsSource $source, FeedsFetcherResult $fetcher_result) {
$feed = new SimpleXMLElement($fetcher_result->getRaw());
$source_feed = $source->config['FeedsHTTPFetcher'];
$user_tags = isset($source_feed['user_tags'][0]) ? explode(',', $source_feed['user_tags']) : array('tag1', 'tag2');
$result = new FeedsParserResult();
$result->title = 'feed importer';
$result->items = array();
#$fetcher_result->
foreach ($feed->channel->item as $item) {
// Skip if title doesn't
if ((string) $item->title) {
$result->items[] = array(
'title' => (string) $item->title,
'callout' => '<p>'.(string) $item->description.'</p>', // wrap light_html in P tags
'pubdate' => (string) $item->pubDate, // _parser_common_syndication_parse_date()
'url' => (string) $item->link,
'image_url' => (string) $item->thumb, // http://placekitten.com/g/200/300
'image_alt' => (string) $item->alt,
'published' => 1,
'tags' => $user_tags,
);
}
}
return $result;
}
I would like to add an additional field for an optional URL. This way the user can include several sources and import from different places at the same time.
I could not find a way to do so. Ideas?