I'm looking for a way to import an RSS feeds into nodes.
This is an example of RSS feeds that I'm trying to import:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>List of changes (3244034544-3243867643)</title>
<link>http://matt.dev.openstreetmap.org/owl_viewer</link>
<description>Changes for range 3244034544-3243867643</description>
<item>
<title>Changeset 7989922 by Drupol</title>
<description>
<![CDATA[<p>By <a href="http://www.openstreetmap.org/user/Drupol">Drupol</a> covering 6 tiles, with comment "Colfontaine et alentours", using "JOSM/1.5 (4021 en)". View changeset on <a href="http://www.openstreetmap.org/browse/changeset/7989922">main OSM site</a>.</p>]]>
</description>
<pubDate>Wed, 27 Apr 2011 23:19:19 +0100</pubDate>
<link>http://matt.dev.openstreetmap.org/owl_viewer/tiles/7989922</link>
<guid>http://matt.dev.openstreetmap.org/owl_viewer/tiles/7989922</guid>
</item>
<item>
<title>Changeset 7989942 by Drupol</title>
<description>
<![CDATA[<p>By <a href="http://www.openstreetmap.org/user/Drupol">Drupol</a> covering 1 tiles, with comment "Colfontaine et alentours", using "JOSM/1.5 (4021 en)". View changeset on <a href="http://www.openstreetmap.org/browse/changeset/7989942">main OSM site</a>.</p>]]>
</description>
<pubDate>Wed, 27 Apr 2011 23:19:19 +0100</pubDate>
<link>http://matt.dev.openstreetmap.org/owl_viewer/tiles/7989942</link>
<guid>http://matt.dev.openstreetmap.org/owl_viewer/tiles/7989942</guid>
</item>
.
.
.
I use the module Feeds and a simple importer to import the data.
What I would like to do is importing the Changeset ID, Username and Comments into CCK fields.
I've created my node 'OSMLOG' and the 3 custom fields.
Back in Feeds, I map the title to the $node->"OSM Chanseget Field", again title to $node->"OSM Username", and software to $node->"OSM Software".
Then I create my own module to work on data before assigning them:
/**
* Implementation of hook_feeds_node_processor_targets_alter().
*/
function mymodule_feeds_node_processor_targets_alter(&$targets, $content_type) {
dpm($content_type);
if ($content_type == 'osmlog') {
$targets['field_osmlog_software'] = array(
'name' => t('OSM Log Software'),
'description' => t('OSM Log Software'),
'callback' => 'mymodule_set_target'
);
$targets['field_osmlog_changeset'] = array(
'name' => t('OSM Log Changeset ID'),
'description' => t('OSM Log Changeset ID'),
'callback' => 'mymodule_set_target'
);
$targets['field_osmlog_user'] = array(
'name' => t('OSM Log User'),
'description' => t('OSM Log User'),
'callback' => 'mymodule_set_target'
);
}
}
/**
* Mapping callback.
*/
function mymodule_set_target($node, $target, $value) {
$node->$target = "Testing";
}
If I do that, nothing is working, it seems that is never goes into the callback. I'm pretty sure that it goes into the hook_feeds_node_processor_targets_alter() but not in the callback. Is there a good documentation on how to setup such things with Feeds ?
mymodule_set_target()
function (it's still commented out).